perf improvements

This commit is contained in:
Michael Freno
2026-01-04 14:53:30 -05:00
parent 111712e969
commit a620a9f4c5
10 changed files with 303 additions and 1750 deletions

View File

@@ -63,6 +63,9 @@ export const model: { [key: string]: string } = {
last_edited_date TEXT
);
CREATE INDEX IF NOT EXISTS idx_posts_category ON Post (category);
CREATE INDEX IF NOT EXISTS idx_posts_published ON Post (published);
CREATE INDEX IF NOT EXISTS idx_posts_date ON Post (date);
CREATE INDEX IF NOT EXISTS idx_posts_published_date ON Post (published, date);
`,
PostLike: `
CREATE TABLE PostLike
@@ -72,6 +75,7 @@ export const model: { [key: string]: string } = {
post_id INTEGER NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_likes_user_post ON PostLike (user_id, post_id);
CREATE INDEX IF NOT EXISTS idx_likes_post_id ON PostLike (post_id);
`,
Comment: `
CREATE TABLE Comment

View File

@@ -105,6 +105,21 @@ export interface PostWithCommentsAndLikes {
total_comments: number;
last_edited_date?: string | null;
}
export interface PostCardData {
id: number;
category: "blog" | "project";
title: string;
subtitle: string;
banner_photo: string;
date?: string | null;
published: number;
author_id: string;
reads: number;
attachments: string;
total_likes: number;
total_comments: number;
}
export interface PostWithTags {
id: number;
category: "blog" | "project"; // this is no longer used