Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/RatingTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ const isModalOpen = ref(false);
>
max endgame size
</th>
<th
scope="col"
class="px-6 py-3"
>
code submissions
</th>
<th
scope="col"
class="px-6 py-3"
Expand Down Expand Up @@ -154,6 +160,9 @@ const isModalOpen = ref(false);
<td class="px-6 py-4">
{{ userRating.avgEndgameSize.toFixed(2) }}
</td>
<td class="px-6 py-4 bg-gray-50 dark:bg-gray-800">
{{ userRating.submissionCount }}
</td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ model User {
password String
username String @unique
game_stats GameStats[]
submissionCount Int @default(0)
}

model Game {
Expand Down
5 changes: 5 additions & 0 deletions server/api/bot/submit.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default defineEventHandler(async (event) => {
});
}

await prisma.user.update({
where: { id: event.context.user.id },
data: { submissionCount: { increment: 1 } },
});

botCodeStore.submitBotCode({
username: event.context.user.username,
userId: event.context.user.id,
Expand Down
6 changes: 5 additions & 1 deletion server/api/rating.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
foodEaten: number;
maxEndgameSize: number;
avgEndgameSize: number;
submissionCount: number;
};

export type UserRating = UserStats & {
Expand Down Expand Up @@ -45,7 +46,9 @@
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

// don't join users to not slow down the games query with another join
const users = await prisma.user.findMany();
const users = await prisma.user.findMany({
select: { id: true, username: true, submissionCount: true }

Check failure on line 50 in server/api/rating.get.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
});
const games = await prisma.game.findMany({
where: { start_time: { gte: oneWeekAgo } },
include: { game_stats: true },
Expand Down Expand Up @@ -75,6 +78,7 @@
const rawUserStat = rawUserStats[stat.user_id] || (rawUserStats[stat.user_id] = {
userId: stat.user_id,
username: user.username,
submissionCount: user.submissionCount,
stats7days: getEmptyRawStats(),
stats24hours: getEmptyRawStats(),
stats1hour: getEmptyRawStats(),
Expand Down
Loading