monkeytype/backend/dao/public-stats.js

23 lines
737 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
static async increment(started, completed, time) {
2021-06-12 20:39:30 +08:00
time = roundTo2(time);
await mongoDB()
2021-07-07 21:05:04 +08:00
.collection("users")
.updateOne({ name: "startedTests" }, { $inc: { value: started } });
2021-06-12 20:39:30 +08:00
await mongoDB()
2021-07-07 21:05:04 +08:00
.collection("users")
.updateOne({ name: "completedTests" }, { $inc: { value: completed } });
2021-06-12 20:39:30 +08:00
await mongoDB()
2021-07-07 21:05:04 +08:00
.collection("users")
.updateOne({ name: "timeTyping" }, { $inc: { value: time } });
2021-06-12 20:39:30 +08:00
return true;
}
}
module.exports = PublicStatsDAO;