-
Notifications
You must be signed in to change notification settings - Fork 52
Db/seeding #296
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
base: main
Are you sure you want to change the base?
Db/seeding #296
Conversation
DVidal1205
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work, just can never fully trust Discord
| for (const role of prodRoles) { | ||
| const hash = role.name + " " + role.permissions; | ||
| if (devRoles[hash]) { | ||
| roleIdMappings[role.id] = devRoles[hash].id; | ||
| } else { | ||
| const newRole = (await discord.post( | ||
| Routes.guildRoles(DEV_KNIGHTHACKS_GUILD_ID), | ||
| { | ||
| body: { | ||
| name: role.name, | ||
| permissions: role.permissions, | ||
| color: role.color, | ||
| hoist: role.hoist, | ||
| mentionable: role.mentionable, | ||
| }, | ||
| }, | ||
| )) as DiscordRole; | ||
| roleIdMappings[role.id] = newRole.id; | ||
| } | ||
| } | ||
|
|
||
| console.log(roleIdMappings); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement a rate limit backoff here. Discord gets pesky. for discord logic have either a set 0.10s delay per operation, or wrap in a try catch block that will check for a 429 and retry after a longer 5 second window. whichever you'd like.
| for (const event of prodEvents) { | ||
| const hash = event.name + " " + event.scheduled_start_time; | ||
| if (devEvents[hash]) { | ||
| eventIdMappings[event.id] = devEvents[hash].id; | ||
| } else { | ||
| const newEvent = (await discord.post( | ||
| Routes.guildScheduledEvents(DEV_KNIGHTHACKS_GUILD_ID), | ||
| { | ||
| body: { | ||
| name: event.name, | ||
| description: event.description, | ||
| scheduled_start_time: event.scheduled_start_time, | ||
| scheduled_end_time: event.scheduled_end_time, | ||
| privacy_level: event.privacy_level, | ||
| entity_type: event.entity_type, | ||
| entity_metadata: event.entity_metadata, | ||
| }, | ||
| }, | ||
| )) as DiscordGuildScheduledEvent; | ||
| eventIdMappings[event.id] = newEvent.id; | ||
| } | ||
| } | ||
|
|
||
| console.log(eventIdMappings); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing as role map
Why
Getting good data into our DB to be used for deving has been a pain forever so we needed a seeding script.
What
This introduces a seeding script and cron job that backs up the prod db (minus all sensitive information) and makes a backup sql file to insert those rows into our local db and saves it on our minio client. The seeding script can then pull this sql script and then fill the local rows with prod data that is fine for the dev team to have.
Test Plan
Idk man there's too many moving parts to take a video or screenshot just ask me lowk 🙏 Ofc feel free to lmk if the usage is too confusing I'll improve the docs and stuff