aboutsummaryrefslogtreecommitdiff
path: root/src/database.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-06-01 17:11:48 -0500
committermat <github@matdoes.dev>2021-06-01 17:11:48 -0500
commitaeb5f0d176d11a3b15d98e136ad9e420fd6cb416 (patch)
tree5344bc05b6aba03bd6461844535b8a48932d8d7a /src/database.ts
parentdecb1a1ee1a35505db7cb573031dd6986d15cdbe (diff)
downloadskyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.tar.gz
skyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.tar.bz2
skyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.zip
don't queue stuff if it's in recentlyUpdated
Diffstat (limited to 'src/database.ts')
-rw-r--r--src/database.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/database.ts b/src/database.ts
index 58e1679..2c0a715 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -543,8 +543,7 @@ export async function updateDatabaseMember(member: CleanMember, profile: CleanFu
if (!client) return // the db client hasn't been initialized
if (debug) console.debug('updateDatabaseMember', member.username)
// the member's been updated too recently, just return
- if (recentlyUpdated.get(profile.uuid + member.uuid))
- return
+ if (recentlyUpdated.get(profile.uuid + member.uuid)) return
// store the member in recentlyUpdated so it cant update for 3 more minutes
recentlyUpdated.set(profile.uuid + member.uuid, true)
@@ -662,11 +661,13 @@ export const leaderboardUpdateProfileQueue = new Queue({
/** Queue an update for the member's leaderboard data on the server if applicable */
export function queueUpdateDatabaseMember(member: CleanMember, profile: CleanFullProfile): void {
+ if (recentlyUpdated.get(profile.uuid + member.uuid)) return
leaderboardUpdateMemberQueue.enqueue(async() => await updateDatabaseMember(member, profile))
}
/** Queue an update for the profile's leaderboard data on the server if applicable */
export function queueUpdateDatabaseProfile(profile: CleanFullProfile): void {
+ if (recentlyUpdated.get(profile.uuid + 'profile')) return
leaderboardUpdateProfileQueue.enqueue(async() => await updateDatabaseProfile(profile))
}