Real-Dev-Squad / website-backend

The backend code for all our website-related apps
https://api.realdevsquad.com/
MIT License
50 stars 212 forks source link

[RFC] Implementation of User Status Update Script #1226

Open heyrandhir opened 1 year ago

heyrandhir commented 1 year ago

We need a script which will automatically mark user status based on the task assigned to them

Approach 1:

This approach directly queries the tasks collection for each user to determine if they have any assigned tasks. If no tasks are found, the user's status is updated to "idle" in the status collection.

The Steps are as follows :

  1. Retrieve all users from the Firestore "users" collection.
  2. For each user, query the "tasks" collection using their ID as the assignee field value to check if they have any assigned tasks.
  3. If the query result is empty, it means the user doesn't have a task assigned. Update their status to "idle" in the "status" collection.
  4. This approach directly checks each user's task assignments to identify idle users and update their status.

Approach 2:

In this approach, all tasks are retrieved from the tasks collection, and the assignees' user IDs are extracted. Then, for each user, their ID is checked against the assignees list. If the user's ID is not present, their status is updated to "idle" in the status collection.

  1. Retrieve all tasks from the Firestore "tasks" collection.
  2. Extract the assignees (user IDs) from the tasks.
  3. Loop through all users and check if their ID is not in the list of assignees.
  4. If a user's ID is not found in the assignees list, update their status to "idle" in the "status" collection.
vikhyat187 commented 1 year ago

IMO the first approach looks good as we only query the users, the second one requires to query tasks then loop over all the users to find the user One question does this mark the Mavens idle?

heyrandhir commented 1 year ago

IMO the first approach looks good as we only query the users, the second one requires to query tasks then loop over all the users to find the user One question does this mark the Mavens idle?

Mavens don't create a account on RDS.