Refactor: Better Post Metrics data fetching
This commit is contained in:
+16
-19
@@ -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)[],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user