monkeytype/backend/dao/public-stats.js

27 lines
655 B
JavaScript
Raw Normal View History

2021-07-07 21:05:04 +08:00
// const MonkeyError = require("../handlers/error");
2021-06-12 20:39:30 +08:00
const { mongoDB } = require("../init/mongodb");
const { roundTo2 } = require("../handlers/misc");
class PublicStatsDAO {
2021-07-07 21:05:04 +08:00
//needs to be rewritten, this is public stats not user stats
2021-08-02 23:21:14 +08:00
static async updateStats(restartCount, time) {
2021-06-12 20:39:30 +08:00
time = roundTo2(time);
await mongoDB()
2021-08-02 23:21:14 +08:00
.collection("public")
.updateOne(
{ type: "stats" },
{
$inc: {
testsCompleted: 1,
testsStarted: restartCount + 1,
timeTyping: time,
},
},
{ upsert: true }
);
2021-06-12 20:39:30 +08:00
return true;
}
}
module.exports = PublicStatsDAO;