Skip to content

Commit

Permalink
Merge pull request #1987 from Real-Dev-Squad/develop
Browse files Browse the repository at this point in the history
Dev to main sync
  • Loading branch information
prakashchoudhary07 committed Mar 26, 2024
2 parents 52d5a4f + 89b8c7e commit cfc516e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ yarn install --frozen-lockfile

This command should be successful, before moving to development.


```shell
yarn validate-setup
```
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const githubAuthCallback = (req, res, next) => {
github_created_at: Number(new Date(user._json.created_at).getTime()),
github_user_id: user.id,
created_at: Date.now(),
updated_at: Date.now(),
updated_at: null,
};

const { userId, incompleteUserDetails, role } = await users.addOrUpdate(userData);
Expand Down
3 changes: 3 additions & 0 deletions controllers/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const updateRoles = async (req, res) => {
...userData.roles,
...req.body,
},
updated_at: Date.now(),
},
userId
);
Expand Down Expand Up @@ -48,6 +49,7 @@ const removePrivileges = async (req, res) => {
...member.roles,
member: false,
},
updated_at: Date.now(),
},
member.id
)
Expand All @@ -61,6 +63,7 @@ const removePrivileges = async (req, res) => {
...superUser.roles,
super_user: false,
},
updated_at: Date.now(),
},
superUser.id
)
Expand Down
2 changes: 2 additions & 0 deletions models/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const moveToMembers = async (userId) => {
const roles = user.roles ? { ...user.roles, member: true } : { member: true };
await userModel.doc(userId).update({
roles,
updated_at: Date.now(),
});
return { isAlreadyMember: false, movedToMember: true };
} catch (err) {
Expand Down Expand Up @@ -101,6 +102,7 @@ const addArchiveRoleToMembers = async (userId) => {
const roles = { ...user.roles, [ROLES.ARCHIVED]: true };
await userModel.doc(userId).update({
roles,
updated_at: Date.now(),
});
return { isArchived: false };
} catch (err) {
Expand Down
8 changes: 5 additions & 3 deletions models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const addOrUpdate = async (userData, userId = null) => {
user = await userModel.where("github_id", "==", userData.github_id).limit(1).get();
}
if (user && !user.empty && user.docs !== null) {
await userModel.doc(user.docs[0].id).set(userData, { merge: true });
await userModel.doc(user.docs[0].id).set({ ...userData, updated_at: Date.now() }, { merge: true });
const data = user.docs[0].data();
return {
isNewUser: false,
Expand Down Expand Up @@ -308,6 +308,7 @@ const setIncompleteUserDetails = async (userId) => {
if (doc.exists) {
return userRef.update({
incompleteUserDetails: false,
updated_at: Date.now(),
});
}
return {};
Expand Down Expand Up @@ -423,6 +424,7 @@ const updateUserPicture = async (image, userId) => {
const userDoc = userModel.doc(userId);
await userDoc.update({
picture: image,
updated_at: Date.now(),
});
} catch (err) {
logger.error("Error updating user picture data", err);
Expand Down Expand Up @@ -788,7 +790,7 @@ const updateUsersInBatch = async (usersData) => {
usersData.forEach((user) => {
const id = user.id;
delete user.id;
bulkWriter.update(userModel.doc(id), user);
bulkWriter.update(userModel.doc(id), { ...user, updated_at: Date.now() });
});

await bulkWriter.close();
Expand Down Expand Up @@ -913,7 +915,7 @@ const addGithubUserId = async (page, size) => {
})
.then((data) => {
const githubUserId = data.id;
batchWrite.update(userDoc.ref, { github_user_id: `${githubUserId}` });
batchWrite.update(userDoc.ref, { github_user_id: `${githubUserId}`, updated_at: Date.now() });
countUserFound++;
})
.catch((error) => {
Expand Down
1 change: 1 addition & 0 deletions services/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const archiveUsers = async (usersData) => {
...user.roles,
archived: true,
},
updated_at: Date.now(),
};
batch.update(userModel.doc(id), updatedUserData);
usersBatch.push({ id, firstName, lastName });
Expand Down

0 comments on commit cfc516e

Please sign in to comment.