Skip to content

Commit cc2dcf6

Browse files
Feat/fake trends v2 (#203)
* feat(trend): increase TTL time for trend just for testing scenarios * test(trend): fix unit tests
1 parent ad6394d commit cc2dcf6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/trend/trend.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ describe('TrendService', () => {
230230
expect.any(Number),
231231
expect.any(String)
232232
);
233-
expect(redis_service.expire).toHaveBeenCalledWith('candidates:active', 6 * 60 * 60);
233+
expect(redis_service.expire).toHaveBeenCalledWith('candidates:active', 24 * 60 * 60);
234234
});
235235
});
236236

@@ -301,7 +301,7 @@ describe('TrendService', () => {
301301
await trend_service.updateHashtagCounts(hashtag_job);
302302

303303
expect(redis_service.zincrby).toHaveBeenCalled();
304-
expect(redis_service.expire).toHaveBeenCalledWith('hashtag:#trending', 6 * 60 * 60);
304+
expect(redis_service.expire).toHaveBeenCalledWith('hashtag:#trending', 24 * 60 * 60);
305305
expect(mock_pipeline.exec).toHaveBeenCalled();
306306
});
307307
});

src/trend/trend.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class TrendService {
143143

144144
//Expire after 2 hours
145145
// We may delegate it to trend worker
146-
await this.redis_service.expire('candidates:active', 6 * 60 * 60);
146+
await this.redis_service.expire('candidates:active', 24 * 60 * 60);
147147
}
148148
async insertCandidateCategories(hashtags: HashtagJobDto) {
149149
const pipeline = this.redis_service.pipeline();
@@ -157,7 +157,7 @@ export class TrendService {
157157
if (percent >= this.CATEGORY_THRESHOLD) {
158158
// Store hashtag with its category percentage as score
159159
pipeline.zadd(`candidates:${category_name}`, percent, hashtag);
160-
pipeline.expire(`candidates:${category_name}`, 6 * 60 * 60);
160+
pipeline.expire(`candidates:${category_name}`, 24 * 60 * 60);
161161
}
162162
}
163163
}
@@ -178,7 +178,7 @@ export class TrendService {
178178

179179
await this.redis_service.zincrby(`hashtag:${hashtag}`, 1, time_bucket.toString());
180180

181-
await this.redis_service.expire(`hashtag:${hashtag}`, 6 * 60 * 60);
181+
await this.redis_service.expire(`hashtag:${hashtag}`, 24 * 60 * 60);
182182
}
183183

184184
await pipeline.exec();

0 commit comments

Comments
 (0)