Skip to content

Commit 2340865

Browse files
fix usage count using resettable token count instead of total tokens
1 parent 97e1d6c commit 2340865

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/server/routes/admin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ const getUsages = async () => {
6262
FROM user_chat_instance_usages u
6363
LEFT JOIN responsibilities r
6464
ON u.user_id = r.user_id AND u.chat_instance_id = r.chat_instance_id
65-
WHERE r.user_id IS NULL AND usage_count > 0;
65+
WHERE r.user_id IS NULL AND total_usage_count > 0;
6666
`)) as any[]
6767

6868
return usages.map((usage) => ({
6969
id: usage.id,
7070
userId: usage.user_id,
71-
usageCount: usage.usage_count,
71+
usageCount: usage.usage_count, //<--- this get reset
72+
totalUsageCount: usage.total_usage_count, //<--- this wont get reset
7273
chatInstanceId: usage.chat_instance_id,
7374
}))
7475
}
@@ -90,7 +91,7 @@ adminRouter.get('/statistics', async (req, res) => {
9091
}
9192
}
9293
courses[usage.chatInstanceId].students += 1
93-
courses[usage.chatInstanceId].usedTokens += usage.usageCount
94+
courses[usage.chatInstanceId].usedTokens += usage.totalUsageCount //we are interested in how many tokens totally are used in a course
9495
}
9596

9697
const getTermsOf = ({ courseActivityPeriod }): Term[] => {

0 commit comments

Comments
 (0)