-
Notifications
You must be signed in to change notification settings - Fork 2
fix(trends): categorize caching #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -580,21 +580,32 @@ export class PostService { | |
|
|
||
| // Emit post.created event for real-time hashtag tracking | ||
| if (hashtagIds.length > 0) { | ||
| let interestSlug: string | undefined; | ||
| if (post.interest_id) { | ||
| const interest = await this.prismaService.interest.findUnique({ | ||
| where: { id: post.interest_id }, | ||
| select: { slug: true }, | ||
| }); | ||
| interestSlug = interest?.slug; | ||
| } | ||
| this.eventEmitter.emit('post.created', { | ||
| postId: post.id, | ||
| userId: post.user_id, | ||
| hashtagIds, | ||
| interestSlug, | ||
| timestamp: post.created_at.getTime(), | ||
| }); | ||
| setTimeout(async () => { | ||
|
||
| try { | ||
| let interestSlug: string | undefined; | ||
| const updatedPost = await this.prismaService.post.findUnique({ | ||
| where: { id: post.id }, | ||
| select: { interest_id: true }, | ||
| }); | ||
|
|
||
| if (updatedPost?.interest_id) { | ||
| const interest = await this.prismaService.interest.findUnique({ | ||
| where: { id: updatedPost.interest_id }, | ||
| select: { slug: true }, | ||
| }); | ||
| interestSlug = interest?.slug; | ||
| } | ||
| this.eventEmitter.emit('post.created', { | ||
| postId: post.id, | ||
| userId: post.user_id, | ||
| hashtagIds, | ||
| interestSlug, | ||
| timestamp: post.created_at.getTime(), | ||
| }); | ||
| } catch (error) { | ||
| console.error('Failed to emit post.created event:', error); | ||
|
||
| } | ||
| }, 1500); | ||
| } | ||
|
|
||
| // Update parent post stats cache if this is a reply or quote | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for excluding GENERAL and PERSONALIZED is redundant since GENERAL is explicitly added at line 415, and PERSONALIZED should not be in CATEGORY_TO_INTERESTS. This filtering suggests a potential misunderstanding of the data structure. Consider validating that CATEGORY_TO_INTERESTS doesn't contain these categories, or document why this defensive check is necessary.