Merge pull request #22646 from overleaf/ar-address-mongo-count-deprecation-warning

[web] Switch from find.count to countDocuments

GitOrigin-RevId: cc607868334d54b3d5c375c06fec97a482a16cc5
This commit is contained in:
Andrew Rumble 2025-02-14 11:50:01 +00:00 committed by Copybot
parent 784d107472
commit ccb2791a0d
2 changed files with 5 additions and 9 deletions

View file

@ -15,12 +15,10 @@ function populateTeamInvites(user, callback) {
async function countActiveUsers() {
const oneYearAgo = new Date()
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1)
return await db.users
.find(
{ lastActive: { $gte: oneYearAgo } },
{ readPreference: READ_PREFERENCE_SECONDARY }
)
.count()
return await db.users.countDocuments(
{ lastActive: { $gte: oneYearAgo } },
{ readPreference: READ_PREFERENCE_SECONDARY }
)
}
module.exports = {

View file

@ -17,9 +17,7 @@ describe('UserHandler', function () {
this.db = {
users: {
find: sinon.stub().returns({
count: sinon.stub().resolves(2),
}),
countDocuments: sinon.stub().resolves(2),
},
}