From 8bc3ebb63b12f6cc2ad8f7cd783809edd01c5440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20=C3=93skarsson?= Date: Sat, 18 Jan 2025 10:38:08 +0100 Subject: [PATCH] broke some types without realizing --- Dockerfile | 2 +- apps/web/src/components/react/tag-controls.tsx | 5 +++-- .../domain/fetch-missing-post-records.ts | 2 +- packages/atproto/domain/get-admin-stats.ts | 17 ++++++++++++++++- packages/atproto/domain/queue-repost.ts | 3 ++- .../atproto/domain/store-post-with-record.ts | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fde36a6..6a7396b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ ENV PATH="/mise/shims:$PATH" RUN curl https://mise.run | sh WORKDIR /home/app -RUN mise use --verbose -g bun@1.1.43 node@lts +RUN mise use --verbose -g bun@1.1.45 node@lts # Deps FROM base as deps diff --git a/apps/web/src/components/react/tag-controls.tsx b/apps/web/src/components/react/tag-controls.tsx index 8de3538..c1b5b52 100644 --- a/apps/web/src/components/react/tag-controls.tsx +++ b/apps/web/src/components/react/tag-controls.tsx @@ -25,12 +25,13 @@ export function TagControls({ postUri }: { postUri: string }) { tags.data.map((tag) => { return { ...tag, - avgScore: + avgScore: Math.floor( tag.scores.length > 0 ? tag.scores.reduce((acc, curr) => { return acc + curr.score; }, 0) / tag.scores.length - : 0, + : 0 + ), }; }) ); diff --git a/packages/atproto/domain/fetch-missing-post-records.ts b/packages/atproto/domain/fetch-missing-post-records.ts index f11cdd5..caf8be2 100644 --- a/packages/atproto/domain/fetch-missing-post-records.ts +++ b/packages/atproto/domain/fetch-missing-post-records.ts @@ -69,7 +69,7 @@ export async function fetchMissingPostRecords(ctx: AtContext) { await tx .insert(postTexts) .values({ - post_id: post.uri, + postId: post.uri, source: et.type, text: et.text, }) diff --git a/packages/atproto/domain/get-admin-stats.ts b/packages/atproto/domain/get-admin-stats.ts index 28c047c..5e5aef9 100644 --- a/packages/atproto/domain/get-admin-stats.ts +++ b/packages/atproto/domain/get-admin-stats.ts @@ -1,6 +1,7 @@ import { count, countDistinct, eq, isNull, sql } from "drizzle-orm"; import type { AtContext } from "../context"; import { postRecords } from "./post/post-record.table"; +import { postTexts } from "./post/post-texts.table"; import { postTable } from "./post/post.table"; import { followTable } from "./user/user-follows.table"; import { didTable } from "./user/user.table"; @@ -42,5 +43,19 @@ export async function getAdminStats(ctx: AtContext) { .leftJoin(postRecords, eq(postTable.id, postRecords.postId)) .where(isNull(postRecords.postId)); - return [...noFollows, ...noPosts, ...noUsers, ...noPostsMissingRecords]; + const noPostsMissingText = await ctx.db + .select({ + label: sql`'Missing text'`, + value: sql`COALESCE(COUNT(${postTable.id}), 0)`, + }) + .from(postTable) + .leftJoin(postTexts, eq(postTable.id, postTexts.postId)) + .where(isNull(postTexts.postId)); + return [ + ...noFollows, + ...noPosts, + ...noUsers, + ...noPostsMissingRecords, + ...noPostsMissingText, + ]; } diff --git a/packages/atproto/domain/queue-repost.ts b/packages/atproto/domain/queue-repost.ts index 5c51dd8..c7a3db5 100644 --- a/packages/atproto/domain/queue-repost.ts +++ b/packages/atproto/domain/queue-repost.ts @@ -57,8 +57,9 @@ export async function queueRePost( .insert(repostTable) .values({ repostUri: repostUri.toString(), - authorId: postMsg.did, + repostAuthorId: postMsg.did, postId: originalUri, + created: new Date(postMsg.commit.record.createdAt), }) .onConflictDoNothing(); } diff --git a/packages/atproto/domain/store-post-with-record.ts b/packages/atproto/domain/store-post-with-record.ts index c0aa948..b0b50d1 100644 --- a/packages/atproto/domain/store-post-with-record.ts +++ b/packages/atproto/domain/store-post-with-record.ts @@ -53,7 +53,7 @@ export async function storePost(ctx: AtContext, post: FeedPostWithUri) { await tx .insert(postTexts) .values({ - post_id: post.uri, + postId: post.uri, source: et.type, text: et.text, }) -- 2.51.2