refactor
This commit is contained in:
parent
4f20c87186
commit
3a4039e2e1
|
@ -47,12 +47,12 @@ export class FeaturedService {
|
||||||
const currentWindow = this.getCurrentWindow(windowRange);
|
const currentWindow = this.getCurrentWindow(windowRange);
|
||||||
const previousWindow = currentWindow - 1;
|
const previousWindow = currentWindow - 1;
|
||||||
|
|
||||||
const [currentRankingResult, previousRankingResult] = await Promise.all([
|
const redisPipeline = this.redisClient.pipeline();
|
||||||
this.redisClient.zrange(
|
redisPipeline.zrange(
|
||||||
`${name}:${currentWindow}`, 0, threshold, 'REV', 'WITHSCORES'),
|
`${name}:${currentWindow}`, 0, threshold, 'REV', 'WITHSCORES');
|
||||||
this.redisClient.zrange(
|
redisPipeline.zrange(
|
||||||
`${name}:${previousWindow}`, 0, threshold, 'REV', 'WITHSCORES'),
|
`${name}:${previousWindow}`, 0, threshold, 'REV', 'WITHSCORES');
|
||||||
]);
|
const [currentRankingResult, previousRankingResult] = await redisPipeline.exec().then(result => result ? result.map(r => r[1] as string[]) : [[], []]);
|
||||||
|
|
||||||
const ranking = new Map<string, number>();
|
const ranking = new Map<string, number>();
|
||||||
for (let i = 0; i < currentRankingResult.length; i += 2) {
|
for (let i = 0; i < currentRankingResult.length; i += 2) {
|
||||||
|
|
Loading…
Reference in New Issue