Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: OOO Nickname Update Job #11

Merged
merged 19 commits into from
Nov 15, 2023

Conversation

bharati-21
Copy link
Contributor

@bharati-21 bharati-21 commented Sep 22, 2023

Feat: 1119 Update User Discord Nickname During OOO

Closes: Real-Dev-Squad/website-backend#1119

  • The following PR contains cron job that triggers the POST /discord-actions/nickname/status API every 6 hours.
  • The job fetches the timestamp of the last updated job and then updates it when the batch update completes successfully.

Warning ⚠️

src/config/config.ts Outdated Show resolved Hide resolved
wrangler.toml Outdated Show resolved Hide resolved
src/worker.ts Outdated Show resolved Hide resolved
src/constants.ts Outdated Show resolved Hide resolved
src/handlers/scheduledEventHandler.ts Show resolved Hide resolved
src/worker.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@RitikJaiswal75 RitikJaiswal75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please share the design doc for implementing this solution.

@bharati-21
Copy link
Contributor Author

Please share the design doc for implementing this solution.

I spoke with Ankush regarding this. I didn't know a design doc was required (the mandate came later). The design doc is still in progress. I've informed him that I'll provide once done.

Copy link
Contributor

@ankushdharkar ankushdharkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good work. Minor questions and suggestions.

src/handlers/scheduledEventHandler.ts Outdated Show resolved Hide resolved
src/handlers/scheduledEventHandler.ts Outdated Show resolved Hide resolved
src/handlers/scheduledEventHandler.ts Show resolved Hide resolved
src/handlers/scheduledEventHandler.ts Outdated Show resolved Hide resolved
src/handlers/scheduledEventHandler.ts Show resolved Hide resolved
try {
token = await generateJwt(env);
} catch (err) {
console.log(`Error while generating JWT token: ${err}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: console.error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the log both console.log and console.error appears as a generic log. But I've changed it to console.error anyway now.

src/worker.ts Outdated Show resolved Hide resolved
src/worker.ts Outdated Show resolved Hide resolved
wrangler.toml Outdated
# binding = "MY_KV_NAMESPACE"
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
kv_namespaces = [
{ binding = "CRON_JOBS_TIMESTAMPS", id = "a5431887e6c94dc9b3e36c35a07081b9" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are public IDs to identify namespaces bound to a single account.

throw new Error("Error while trying to update users' discord nickname");
}

console.log(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

async scheduled(req: ScheduledController, env: env, ctx: ExecutionContext) {
switch (req.cron) {
case EVERY_4_HOURS:
ctx.waitUntil(ping(env));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this notify us when backend is down?

@ankushdharkar ankushdharkar merged commit 4cd05df into develop Nov 15, 2023
1 check passed
@ankushdharkar ankushdharkar deleted the Feature/1119-OOO-Nickname-Update branch November 15, 2023 13:33
@bharati-21 bharati-21 mentioned this pull request Nov 17, 2023
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API to change users' discord nickname
4 participants