Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: closes #12158, add sortable rewards
convert rewards:list to a sorted set
- Loading branch information
1 parent
7fba622
commit 5ea7dec
Showing
4 changed files
with
90 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
|
||
'use strict'; | ||
|
||
const db = require('../../database'); | ||
|
||
module.exports = { | ||
name: 'Convert rewards:list to a sorted set', | ||
timestamp: Date.UTC(2023, 10, 10), | ||
method: async function () { | ||
const rewards = await db.getSetMembers('rewards:list'); | ||
if (rewards.length) { | ||
rewards.sort((a, b) => a - b); | ||
await db.delete('rewards:list'); | ||
await db.sortedSetAdd( | ||
'rewards:list', | ||
rewards.map((id, index) => index), | ||
rewards.map(id => id) | ||
); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters