Skip to content

Commit

Permalink
Merge branch 'master' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Sep 28, 2023
2 parents db91549 + 6bc312e commit 3e2d607
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/services/cronJobs/checkProjectVerificationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,18 @@ export const checkProjectVerificationStatus = async () => {
foundProjectsCount: projects?.length,
});

// Run all iterations async, resulting in array of promises
await Promise.all(projects.map(remindUpdatesOrRevokeVerification));
for (const project of projects) {
try {
await remindUpdatesOrRevokeVerification(project);
} catch (error) {
logger.error('Error in remindUpdatesOrRevokeVerification', {
projectId: project.id,
projectSlug: project.slug,
projectVerificationStatus: project.verificationStatus,
error,
});
}
}

if (projects.length > 0) {
await Promise.all([
Expand All @@ -109,6 +119,11 @@ export const checkProjectVerificationStatus = async () => {
};

const remindUpdatesOrRevokeVerification = async (project: Project) => {
logger.debug('remindUpdatesOrRevokeVerification() has been called', {
projectId: project.id,
projectSlug: project.slug,
projectVerificationStatus: project.verificationStatus,
});
// Projects up for revoking when 30 days are done after feature release
if (
new Date() >= new Date(projectUpdatesFirstRevokeBatchDate) &&
Expand Down Expand Up @@ -182,7 +197,7 @@ const remindUpdatesOrRevokeVerification = async (project: Project) => {
const user = await User.findOne({ where: { id: Number(project.admin) } });

await sendProperNotification(project, project.verificationStatus as string);
await sleep(1000);
await sleep(300);
};

const sendProperNotification = (
Expand Down

0 comments on commit 3e2d607

Please sign in to comment.