Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerFisher committed Dec 27, 2024
1 parent 4cbe075 commit a82211e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions app/routes/links/topten.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,13 @@ const TopTen = ({ loaderData }: Route.ComponentProps) => {
layout={layout}
toolbar={false}
/>
<Text as="p">
<Text as="p" mt="-3" mb="4">
This link has been seen{" "}
<strong>{linkPost.count.toLocaleString()}</strong> times.
<strong>{linkPost.count.toLocaleString("en-US")}</strong>{" "}
times.
</Text>
<Heading size="3" as="h5" mt="3">
Most popular post, seen {linkPost.posts[0].count} times
</Heading>
{linkPost.posts && (
<Box mt="-4">
<>
<PostRep
group={linkPost.posts.map((post) => ({
...post,
Expand All @@ -194,7 +192,14 @@ const TopTen = ({ loaderData }: Route.ComponentProps) => {
bsky={undefined}
toolbar={false}
/>
</Box>
<Text as="p" mt="3">
Most popular post, seen{" "}
<strong>
{linkPost.posts[0].count.toLocaleString("en-US")}
</strong>{" "}
times
</Text>
</>
)}
<Separator size="4" my="7" />
</Box>
Expand Down
4 changes: 2 additions & 2 deletions app/utils/links.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ interface TopTenLinks {
export interface TopTenResults {
count: number;
link: typeof link.$inferSelect | null;
posts?: (typeof linkPostDenormalized.$inferSelect)[];
posts?: (typeof linkPostDenormalized.$inferSelect & { count: number })[];
mostRecentPostDate: Date;
}

Expand All @@ -384,7 +384,7 @@ export const networkTopTen = async (time: number): Promise<TopTenResults[]> => {
const postsPromise = results.map(async (result) => {
const post = await db
.select({
...linkPostDenormalized,
...getTableColumns(linkPostDenormalized),
count:
sql<number>`count(*) OVER (PARTITION BY ${linkPostDenormalized.postUrl})`.as(
"count",
Expand Down

0 comments on commit a82211e

Please sign in to comment.