diff options
author | mat <github@matdoes.dev> | 2021-06-01 17:11:48 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-01 17:11:48 -0500 |
commit | aeb5f0d176d11a3b15d98e136ad9e420fd6cb416 (patch) | |
tree | 5344bc05b6aba03bd6461844535b8a48932d8d7a | |
parent | decb1a1ee1a35505db7cb573031dd6986d15cdbe (diff) | |
download | skyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.tar.gz skyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.tar.bz2 skyblock-api-aeb5f0d176d11a3b15d98e136ad9e420fd6cb416.zip |
don't queue stuff if it's in recentlyUpdated
-rw-r--r-- | build/database.js | 4 | ||||
-rw-r--r-- | src/database.ts | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/build/database.js b/build/database.js index f3d676c..381be7c 100644 --- a/build/database.js +++ b/build/database.js @@ -512,11 +512,15 @@ exports.leaderboardUpdateProfileQueue = new queue_promise_1.default({ }); /** Queue an update for the member's leaderboard data on the server if applicable */ function queueUpdateDatabaseMember(member, profile) { + if (recentlyUpdated.get(profile.uuid + member.uuid)) + return; exports.leaderboardUpdateMemberQueue.enqueue(async () => await updateDatabaseMember(member, profile)); } exports.queueUpdateDatabaseMember = queueUpdateDatabaseMember; /** Queue an update for the profile's leaderboard data on the server if applicable */ function queueUpdateDatabaseProfile(profile) { + if (recentlyUpdated.get(profile.uuid + 'profile')) + return; exports.leaderboardUpdateProfileQueue.enqueue(async () => await updateDatabaseProfile(profile)); } exports.queueUpdateDatabaseProfile = queueUpdateDatabaseProfile; 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)) } |