mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-26 02:30:07 +02:00
[web] Switch from find.count to countDocuments GitOrigin-RevId: cc607868334d54b3d5c375c06fec97a482a16cc5
32 lines
837 B
JavaScript
32 lines
837 B
JavaScript
const { callbackify, promisify } = require('@overleaf/promise-utils')
|
|
const TeamInvitesHandler = require('../Subscription/TeamInvitesHandler')
|
|
const {
|
|
db,
|
|
READ_PREFERENCE_SECONDARY,
|
|
} = require('../../infrastructure/mongodb')
|
|
|
|
function populateTeamInvites(user, callback) {
|
|
TeamInvitesHandler.createTeamInvitesForLegacyInvitedEmail(
|
|
user.email,
|
|
callback
|
|
)
|
|
}
|
|
|
|
async function countActiveUsers() {
|
|
const oneYearAgo = new Date()
|
|
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1)
|
|
return await db.users.countDocuments(
|
|
{ lastActive: { $gte: oneYearAgo } },
|
|
{ readPreference: READ_PREFERENCE_SECONDARY }
|
|
)
|
|
}
|
|
|
|
module.exports = {
|
|
populateTeamInvites,
|
|
countActiveUsers: callbackify(countActiveUsers),
|
|
}
|
|
module.exports.promises = {
|
|
populateTeamInvites: promisify(populateTeamInvites),
|
|
countActiveUsers,
|
|
}
|