monkeytype/backend/dal/public-stats.ts
Bruce Berrios e5c295cfe4
Remove class syntax from db client (#2940) Bruception
Co-authored-by: Jack <jack@monkeytype.com>
2022-05-05 01:57:51 +02:00

20 lines
446 B
TypeScript

import * as db from "../init/db";
import { roundTo2 } from "../utils/misc";
export async function updateStats(
restartCount: number,
time: number
): Promise<boolean> {
await db.collection<MonkeyTypes.PublicStats>("public").updateOne(
{ type: "stats" },
{
$inc: {
testsCompleted: 1,
testsStarted: restartCount + 1,
timeTyping: roundTo2(time),
},
},
{ upsert: true }
);
return true;
}