오류 수정, 통계 보강

This commit is contained in:
2025-06-08 20:21:37 +09:00
parent 1a3706d7a5
commit 141a0de6d0
42 changed files with 2645 additions and 799 deletions
+106 -14
View File
@@ -105,6 +105,76 @@
</table>
</div>
</div>
<!-- ===== 추가 통계 표시 영역 ===== -->
<!-- 1. 회원별 최고/최저/총점 -->
<h3>회원별 최고/최저/총점</h3>
<table>
<thead>
<tr><th>이름</th><th>최고점</th><th>최저점</th><th>총점</th></tr>
</thead>
<tbody>
<tr v-for="m in stats.memberScoreStats" :key="m.memberId">
<td>{{ m.name }}</td>
<td>{{ m.maxScore }}</td>
<td>{{ m.minScore }}</td>
<td>{{ m.totalScore }}</td>
</tr>
</tbody>
</table>
<!-- 2. 모임별 최고/최저/평균점수 -->
<h3>모임별 점수 통계(확장)</h3>
<table>
<thead>
<tr><th>모임명</th><th>최고점</th><th>최저점</th><th>평균점</th></tr>
</thead>
<tbody>
<tr v-for="e in stats.meetingScoreStats" :key="e.eventId">
<td>{{ e.title }}</td>
<td>{{ e.maxScore }}</td>
<td>{{ e.minScore }}</td>
<td>{{ e.avgScore }}</td>
</tr>
</tbody>
</table>
<!-- 4. 참가자 변화 추이 (그래프) -->
<h3>참가자 변화 추이</h3>
<LineChart v-if="participantTrendChartData" :data="participantTrendChartData" />
<!-- 5. 회원별 모임 참가 횟수 -->
<h3>회원별 모임 참가 횟수</h3>
<table>
<thead>
<tr><th>이름</th><th>참가 횟수</th></tr>
</thead>
<tbody>
<tr v-for="m in stats.memberAttendanceStats" :key="m.memberId">
<td>{{ m.name }}</td>
<td>{{ m.attendCount }}</td>
</tr>
</tbody>
</table>
<!-- 6. 팀별 통계 -->
<h3>팀별 통계</h3>
<table>
<thead>
<tr><th>이벤트ID</th><th>팀ID</th><th>평균점수</th><th>최고점</th><th>참가자수</th></tr>
</thead>
<tbody>
<tr v-for="t in stats.teamStats" :key="`${t.eventId}-${t.teamId}`">
<td>{{ t.eventId }}</td>
<td>{{ t.teamId }}</td>
<td>{{ t.avgScore }}</td>
<td>{{ t.maxScore }}</td>
<td>{{ t.memberCount }}</td>
</tr>
</tbody>
</table>
<!-- ===== 추가 통계 표시 영역 ===== -->
</div>
</div>
</template>
@@ -119,10 +189,7 @@ ChartJS.register(CategoryScale, LinearScale, BarElement, LineElement, PointEleme
export default {
name: 'Statistics',
components: {
BarChart,
LineChart
},
components: { BarChart, LineChart },
setup() {
const stats = ref({
summary: {},
@@ -144,9 +211,11 @@ export default {
});
stats.value = response.data;
console.log('[통계] API 응답:', response.data);
} catch (error) {
console.error('통계 데이터 로드 오류:', error);
} finally {
console.log('[통계] 최종 stats 상태:', stats.value);
loading.value = false;
}
};
@@ -194,18 +263,39 @@ export default {
const attendanceTrendChartOptions = {
responsive: true,
plugins: {
legend: {
display: false
}
legend: { display: false }
},
scales: {
y: {
beginAtZero: true,
max: 100
}
}
scales: { y: { beginAtZero: true, max: 100 } }
};
// 추가 통계용 차트 데이터 (순서 주의!)
const participantTrendChartData = computed(() => {
const arr = stats.value.participantTrend || [];
return {
labels: arr.map(x => formatDate(x.date)),
datasets: [{
label: '참가자 수',
data: arr.map(x => x.participantCount),
backgroundColor: '#42b983',
borderColor: '#42b983',
fill: false
}]
};
});
function getHandicapTrendChartData(trendArr) {
if (!trendArr) return null;
return {
labels: trendArr.map(t => formatDate(t.date)),
datasets: [{
label: '평균 핸디캡',
data: trendArr.map(t => t.avgHandicap),
borderColor: '#f87979',
fill: false
}]
};
}
onMounted(() => {
loadStatistics();
});
@@ -219,7 +309,9 @@ export default {
scoreDistributionChartData,
scoreDistributionChartOptions,
attendanceTrendChartData,
attendanceTrendChartOptions
attendanceTrendChartOptions,
participantTrendChartData,
getHandicapTrendChartData
};
}
};