Add: Edit Count

This commit is contained in:
Donatas Kirda 2024-05-15 18:46:36 +03:00
parent 7ece3268fc
commit bc6d425489
Signed by: bloodwiing
GPG Key ID: 63020D8D3F4A164F
4 changed files with 13 additions and 3 deletions

View File

@ -156,6 +156,8 @@
<tr><td>Author</td><td>{post.author?.id}</td></tr>
<tr><td>Created Date</td><td>{post.postDate}</td></tr>
<tr><td>Score</td><td>{post.rating.likes - post.rating.dislikes}</td></tr>
<tr><td>Edited</td><td>{post.edited ? "Yes" : "No"}</td></tr>
<tr><td>Edit Count</td><td>{post.editCount}</td></tr>
{#if post.metrics}
<tr><td>Comment Count</td><td>{post.metrics.commentCount}</td></tr>
<tr><td>User Count</td><td>{post.metrics.userCount}</td></tr>

View File

@ -15,6 +15,8 @@ function parseCommentFromRow(author, row) {
author: author,
parentCommentId: row['parent_comment_id'],
content: row['latest_content'],
edited: row['edit_count'] == 1,
editCount: row['edit_count'] - 1,
commentDate: row['created_date'],
rating: {
likes: BigInt(row['likes']),
@ -30,7 +32,7 @@ function parseCommentFromRow(author, row) {
*/
export async function getCommentsForPost(sql, post_id) {
const query = sql`
SELECT id, author_id, latest_content, parent_comment_id, created_date, likes, dislikes
SELECT id, author_id, latest_content, edit_count, parent_comment_id, created_date, likes, dislikes
FROM doki8902.message_comment
WHERE post_id = ${ post_id };`;

View File

@ -35,6 +35,8 @@ function parsePostFromRow(author, category, row, withMetrics = false) {
name: row['name'],
category: category,
content: row['latest_content'],
edited: row['edit_count'] > 1,
editCount: row['edit_count'] - 1,
postDate: row['created_date'],
rating: {
likes: BigInt(row['likes']),
@ -66,7 +68,7 @@ export async function getPosts(sql, opts = {}) {
const metrics = withMetrics ? sql`, comment_count, user_count, latest_activity, engagement, age, relevancy` : sql``;
const query = sql`
SELECT id, author_id, name, category_id, latest_content, created_date, likes, dislikes ${ metrics }
SELECT id, author_id, name, category_id, latest_content, edit_count, created_date, likes, dislikes ${ metrics }
FROM doki8902.message_post
${ filter }
FETCH FIRST ${ limit } ROWS ONLY
@ -105,7 +107,7 @@ export async function getPost(sql, post_id, opts = {}) {
const metrics = withMetrics ? sql`, comment_count, user_count, latest_activity, engagement, age, relevancy` : sql``;
const query = sql`
SELECT id, author_id, name, category_id, latest_content, created_date, likes, dislikes ${ metrics }
SELECT id, author_id, name, category_id, latest_content, edit_count, created_date, likes, dislikes ${ metrics }
FROM doki8902.message_post
WHERE id = ${ post_id };`;

View File

@ -31,6 +31,8 @@ export type Post = {
name: string,
category: Category,
content: string,
edited: boolean,
editCount: number,
postDate: Date,
rating: Rating,
metrics: PostMetrics | null,
@ -40,6 +42,8 @@ export type Comment = {
id: number,
author: User | null,
content: string,
edited: boolean,
editCount: number,
commentDate: Date,
rating: Rating,
parentCommentId: number,