Refactor: Better Post Metrics data fetching

This commit is contained in:
2024-05-15 00:41:28 +03:00
parent 196166897e
commit a6f3c6c695
8 changed files with 154 additions and 77 deletions
+16 -19
View File
@@ -3,19 +3,28 @@ export type Result<T> = Map<number, T>;
export type User = {
id: number,
name: string,
joinDate: Date
joinDate: Date,
};
export type Rating = {
likes: bigint,
dislikes: bigint
dislikes: bigint,
}
export type Category = {
id: number,
name: string
name: string,
}
export type PostMetrics = {
commentCount: bigint,
userCount: bigint,
latestActivity: Date,
engagement: bigint,
age: number,
relevancy: number,
};
export type Post = {
id: number,
author: User | null,
@@ -23,7 +32,8 @@ export type Post = {
category: Category,
content: string,
postDate: Date,
rating: Rating
rating: Rating,
metrics: PostMetrics | null,
};
export type Comment = {
@@ -32,23 +42,10 @@ export type Comment = {
content: string,
commentDate: Date,
rating: Rating,
parentCommentId: number
parentCommentId: number,
};
export type CommentTreeNode = {
parent: Comment,
children: (CommentTreeNode | number)[]
};
export type PostMetrics = {
post: Post,
commentCount: bigint,
userCount: bigint,
latestActivity: Date,
rating: Rating,
score: bigint,
engagement: bigint,
age: number,
relevancy: number
children: (CommentTreeNode | number)[],
};