I use node js technology, write backend in express js and database in mongoose
I'm having a "User" Model as follows:
{_id: ObjectId,
name: string,
score: number,
timeStamp: Date}
For example, if a user answers a question, I will find and update that user's "score" field.
But I don't know get the most active users by day, week, and month, yesterday, last week, and last month, based on activity scoring criteria for each time period.
For example, to be the most active user today, I would have to calculate the change in each user's field score from the beginning of the day to the current time
Help me and thanks a million!
Is it necessary to use cronjob and create fields like "today's score" field, and "this month's score" field, then every time the "score" field changes, it will be updated to "today's score" field, "this month's score" field?