Skip to content

Commit aef4f30

Browse files
committed
✨ FEAT: 관리자 대시보드에 매출 통계 그래프 추가
1 parent dc9717e commit aef4f30

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

admin_portal/templates/admin_portal/dashboard.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ <h1 class="text-3xl font-bold text-gray-900">관리자 대시보드</h1>
7070
{% include 'admin_portal/dashboard_components/chart_container.html' with title='수강신청 및 학습 통계' chart_id='enrollmentStatsChart' period_class='enrollment-period-btn' %}
7171

7272
{% include 'admin_portal/dashboard_components/chart_container.html' with title='동영상 조회수 통계' chart_id='videoViewsChart' period_class='video-period-btn' %}
73+
74+
{% include 'admin_portal/dashboard_components/chart_container.html' with title='매출 통계' chart_id='revenueStatsChart' period_class='revenue-period-btn' %}
7375
</div>
7476

7577
<!-- 인기 과정 및 최근 활동 영역 -->
@@ -158,9 +160,22 @@ <h1 class="text-3xl font-bold text-gray-900">관리자 대시보드</h1>
158160
}
159161
];
160162

163+
// 매출 통계 차트
164+
const revenueDatasets = [
165+
{
166+
label: '일일 매출',
167+
data: chartData.revenue,
168+
borderColor: 'rgb(34, 197, 94)',
169+
backgroundColor: 'rgba(34, 197, 94, 0.1)',
170+
tension: 0.4,
171+
fill: true
172+
}
173+
];
174+
161175
const userChart = initChart('userStatsChart', chartData.dates, userDatasets);
162176
const enrollmentChart = initChart('enrollmentStatsChart', chartData.dates, enrollmentDatasets);
163177
const videoChart = initChart('videoViewsChart', chartData.dates, videoDatasets);
178+
const revenueChart = initChart('revenueStatsChart', chartData.dates, revenueDatasets);
164179

165180
// 기간 버튼 핸들러 설정
166181
function setupPeriodButtons(buttonClass, chart, datasetNames) {
@@ -208,6 +223,7 @@ <h1 class="text-3xl font-bold text-gray-900">관리자 대시보드</h1>
208223
setupPeriodButtons('period-btn', userChart, ['new_users', 'active_users']);
209224
setupPeriodButtons('enrollment-period-btn', enrollmentChart, ['new_enrollments']);
210225
setupPeriodButtons('video-period-btn', videoChart, ['completed_lectures']);
226+
setupPeriodButtons('revenue-period-btn', revenueChart, ['revenue']);
211227
});
212228
</script>
213229
{% endblock %}

admin_portal/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def get_context_data(self, **kwargs):
111111
active_users_data = [stat.active_users for stat in daily_stats]
112112
new_enrollments_data = [stat.new_enrollments for stat in daily_stats]
113113
video_views_data = [stat.completed_lectures for stat in daily_stats]
114+
revenue_data = [float(stat.revenue) for stat in daily_stats]
114115

115116
# 차트 데이터 JSON 형식으로 변환
116117
chart_data = {
@@ -119,6 +120,7 @@ def get_context_data(self, **kwargs):
119120
"active_users": active_users_data,
120121
"new_enrollments": new_enrollments_data,
121122
"completed_lectures": video_views_data,
123+
"revenue": revenue_data,
122124
}
123125

124126
context["chart_data"] = json.dumps(chart_data)
@@ -157,6 +159,7 @@ def get(self, request, *args, **kwargs):
157159
"new_enrollments": [stat.new_enrollments for stat in stats],
158160
"completed_lectures": [stat.completed_lectures for stat in stats],
159161
"certificates_issued": [stat.certificates_issued for stat in stats],
162+
"revenue": [float(stat.revenue) for stat in stats],
160163
}
161164

162165
return JsonResponse(data)

0 commit comments

Comments
 (0)