mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-02 12:00:10 +08:00
3566992e45
* Migrate some DAO to ts * Oops * Added constant name
25 lines
586 B
TypeScript
25 lines
586 B
TypeScript
import db from "../init/db";
|
|
import { roundTo2 } from "../utils/misc";
|
|
|
|
class PublicStatsDAO {
|
|
//needs to be rewritten, this is public stats not user stats
|
|
static async 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;
|
|
}
|
|
}
|
|
|
|
export default PublicStatsDAO;
|