File tree Expand file tree Collapse file tree 4 files changed +20
-11
lines changed
cron/src/services/FeedService
packages/database/src/velog-redis Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ interface Service {
12
12
@injectable ( )
13
13
@singleton ( )
14
14
export class FeedService implements Service {
15
- constructor (
15
+ constructor (
16
16
private readonly db : DbService ,
17
17
private readonly utils : UtilsService ,
18
18
private readonly followUserService : FollowUserService ,
Original file line number Diff line number Diff line change @@ -15,10 +15,7 @@ interface Service {
15
15
@injectable ( )
16
16
@singleton ( )
17
17
export class FeedService implements Service {
18
- constructor (
19
- private readonly db : DbService ,
20
- private readonly utils : UtilsService ,
21
- ) { }
18
+ constructor ( private readonly db : DbService , private readonly utils : UtilsService ) { }
22
19
async getFeedPosts ( input : FeedPostsInput , singedUserId ?: string ) : Promise < Post [ ] > {
23
20
if ( ! singedUserId ) {
24
21
return [ ]
Original file line number Diff line number Diff line change @@ -405,7 +405,19 @@ export class PostService implements Service {
405
405
}
406
406
}
407
407
public async updatePostScore ( postId : string ) {
408
+ console . log ( 'upodatePostScore' , postId )
408
409
await this . redis . addToScorePostQueue ( { post_id : postId } )
410
+ try {
411
+ await axios . patch (
412
+ `${ ENV . cronHost } /api/posts/v1/score/${ postId } ` ,
413
+ { } ,
414
+ {
415
+ headers : {
416
+ 'Cron-Api-Key' : ENV . cronApiKey ,
417
+ } ,
418
+ } ,
419
+ )
420
+ } catch ( _ ) { }
409
421
}
410
422
public shortDescription ( post : Post ) : string {
411
423
if ( post . short_description ) return post . short_description
Original file line number Diff line number Diff line change @@ -59,19 +59,19 @@ export class RedisService extends Redis.default implements Service {
59
59
}
60
60
}
61
61
62
- public addToCreateFeedQueue ( data : CreateFeedQueueData ) {
62
+ public async addToCreateFeedQueue ( data : CreateFeedQueueData ) : Promise < number > {
63
63
const queueName = this . queueName . createFeed
64
- return this . lpush ( queueName , JSON . stringify ( data ) )
64
+ return await this . lpush ( queueName , JSON . stringify ( data ) )
65
65
}
66
66
67
- public addToCheckPostSpamQueue ( data : CheckPostSpamQueueData ) : Promise < number > {
67
+ public async addToCheckPostSpamQueue ( data : CheckPostSpamQueueData ) : Promise < number > {
68
68
const queueName = this . queueName . checkPostSpam
69
- return this . lpush ( queueName , JSON . stringify ( data ) )
69
+ return await this . lpush ( queueName , JSON . stringify ( data ) )
70
70
}
71
71
72
- public addToScorePostQueue ( data : ScorePostQueueData ) : Promise < number > {
72
+ public async addToScorePostQueue ( data : ScorePostQueueData ) : Promise < number > {
73
73
const queueName = this . queueName . scorePost
74
- return this . lpush ( queueName , JSON . stringify ( data ) )
74
+ return await this . lpush ( queueName , JSON . stringify ( data ) )
75
75
}
76
76
}
77
77
You can’t perform that action at this time.
0 commit comments