Skip to content

Commit

Permalink
refactor: Update update_users_activity_status to use forEach instead …
Browse files Browse the repository at this point in the history
…of for loop
  • Loading branch information
FelipeCarillo committed Jun 9, 2024
1 parent 936adf0 commit 84bce6e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/core/repositories/database/repositories/ActivityRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,20 +439,21 @@ export class ActivityRepo implements IActivityRepo {
async update_users_activity_status(activity_id: string, users: { user_id: string, status: boolean }[]): Promise<boolean> {
let response = true;

for (const user of users) {
const [affectedCount] = await ActivityApplication.update({
users.forEach(async user => {
const response_user = await ActivityApplication.update({
status: user.status
}, {
where: {
activity_id: activity_id,
user_id: user.user_id
[Op.and]: [
{ activity_id: activity_id },
{ user_id: user.user_id }
]
}
});

if (affectedCount === 0) {
if (response_user[0] === 0) {
response = false;
}
}
});

return response;
}
Expand Down

0 comments on commit 84bce6e

Please sign in to comment.