Skip to content

Commit 0ee511e

Browse files
committed
fix: add update post score routes
1 parent 72bccf1 commit 0ee511e

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

apps/cron/src/services/FeedService/index.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Service {
1212
@injectable()
1313
@singleton()
1414
export class FeedService implements Service {
15-
constructor(
15+
constructor(
1616
private readonly db: DbService,
1717
private readonly utils: UtilsService,
1818
private readonly followUserService: FollowUserService,

apps/server/src/services/FeedService/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ interface Service {
1515
@injectable()
1616
@singleton()
1717
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) {}
2219
async getFeedPosts(input: FeedPostsInput, singedUserId?: string): Promise<Post[]> {
2320
if (!singedUserId) {
2421
return []

apps/server/src/services/PostService/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,19 @@ export class PostService implements Service {
405405
}
406406
}
407407
public async updatePostScore(postId: string) {
408+
console.log('upodatePostScore', postId)
408409
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 (_) {}
409421
}
410422
public shortDescription(post: Post): string {
411423
if (post.short_description) return post.short_description

packages/database/src/velog-redis/index.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ export class RedisService extends Redis.default implements Service {
5959
}
6060
}
6161

62-
public addToCreateFeedQueue(data: CreateFeedQueueData) {
62+
public async addToCreateFeedQueue(data: CreateFeedQueueData): Promise<number> {
6363
const queueName = this.queueName.createFeed
64-
return this.lpush(queueName, JSON.stringify(data))
64+
return await this.lpush(queueName, JSON.stringify(data))
6565
}
6666

67-
public addToCheckPostSpamQueue(data: CheckPostSpamQueueData): Promise<number> {
67+
public async addToCheckPostSpamQueue(data: CheckPostSpamQueueData): Promise<number> {
6868
const queueName = this.queueName.checkPostSpam
69-
return this.lpush(queueName, JSON.stringify(data))
69+
return await this.lpush(queueName, JSON.stringify(data))
7070
}
7171

72-
public addToScorePostQueue(data: ScorePostQueueData): Promise<number> {
72+
public async addToScorePostQueue(data: ScorePostQueueData): Promise<number> {
7373
const queueName = this.queueName.scorePost
74-
return this.lpush(queueName, JSON.stringify(data))
74+
return await this.lpush(queueName, JSON.stringify(data))
7575
}
7676
}
7777

0 commit comments

Comments
 (0)