diff --git a/apps/web/src/components/react/bluesky/feed-post-list.tsx b/apps/web/src/components/react/bluesky/feed-post-list.tsx index f5642ac..243b774 100644 --- a/apps/web/src/components/react/bluesky/feed-post-list.tsx +++ b/apps/web/src/components/react/bluesky/feed-post-list.tsx @@ -17,6 +17,7 @@ export function BskyFeedPostList({ uri={p.post} mayClassify={mayClassify} reason={p.reason} + feedContext={p.feedContext} /> ))} diff --git a/apps/web/src/components/react/bluesky/post-view.tsx b/apps/web/src/components/react/bluesky/post-view.tsx index 4ea821a..474514b 100644 --- a/apps/web/src/components/react/bluesky/post-view.tsx +++ b/apps/web/src/components/react/bluesky/post-view.tsx @@ -127,6 +127,7 @@ export function PostView({ Repost )} + {feedContext &&
{feedContext}
} >["data"], + undefined +>[number] & { + avgScore?: number; +}; + export function TagControls({ postUri }: { postUri: string }) { - const [tags, setTags] = useState< - Exclude< - Awaited>["data"], - undefined - > - >([]); + const [tags, setTags] = useState>([]); useEffect(() => { actions.getTagsForPost({ postUri }).then((tags) => { if (tags.error) return []; - setTags(tags.data); + setTags( + tags.data.map((tag) => { + return { + ...tag, + avgScore: + tag.scores.length > 0 + ? tag.scores.reduce((acc, curr) => { + return acc + curr.score; + }, 0) / tag.scores.length + : 0, + }; + }) + ); }); }, []); @@ -58,55 +72,54 @@ export function TagControls({ postUri }: { postUri: string }) { // TODO: Show that it's tagged now } - const avgScore = useMemo(() => { - const totalScores = tags.reduce((acc, tag) => { - const sum = tag.scores.reduce((sum, score) => sum + score.score, 0); - if (sum === 0) return acc; - return acc + sum / tag.scores.length; - }, 0); - - return Math.floor(totalScores / tags.length); - }, [tags]); - return ( - +
{tags && - tags.map((tag) => ( - - - {`#${tag.tag}`}{" "} - = 80 && "text-green-700", - avgScore < 80 && "text-orange-700", - avgScore <= 50 && "text-red-700" - )} - > - {avgScore}% - - + tags + .filter((tag) => tag.avgScore !== undefined) + .map((tag) => ( +
+
+ + {`#${tag.tag}`}{" "} + = 80 && "text-green-700", + tag.avgScore! < 80 && "text-orange-700", + tag.avgScore! <= 50 && "text-red-700" + )} + > + {tag.avgScore}% + + - - - - - {tag.scores.map((cl) => ( - - {cl.score} % - - ))} - - ))} - + + + + +
+ + {tag.scores.map((cl) => ( + + {cl.score} % + + ))} + +
+ ))} +
); } diff --git a/apps/web/src/pages/admin/feed/[rkey]/index.astro b/apps/web/src/pages/admin/feed/[rkey]/index.astro index 1c8991a..e48d570 100644 --- a/apps/web/src/pages/admin/feed/[rkey]/index.astro +++ b/apps/web/src/pages/admin/feed/[rkey]/index.astro @@ -1,5 +1,5 @@ --- -import { DEFAULT_FEED_ACTOR, feeds, getPublicPosts } from "@andrioid/atproto"; +import { DEFAULT_FEED_ACTOR, feeds } from "@andrioid/atproto"; import Layout from "~astro/layout.astro"; import PageLayout from "~astro/page-layout.astro"; import { BskyFeedPostList } from "~react/bluesky/feed-post-list"; @@ -15,7 +15,6 @@ const res = await feed.handler({ actorDid: DEFAULT_FEED_ACTOR, }); const postUris = res.feed.map((p) => p.post); -const posts = await getPublicPosts(postUris); const mayClassify = Astro.locals.mayClassify; --- diff --git a/apps/web/src/pages/admin/index.astro b/apps/web/src/pages/admin/index.astro index 5727be8..b48e7e9 100644 --- a/apps/web/src/pages/admin/index.astro +++ b/apps/web/src/pages/admin/index.astro @@ -1,11 +1,15 @@ --- -import { getAdminStats, getModerationPosts } from "@andrioid/atproto"; +import { DEFAULT_FEED_ACTOR, feeds, getAdminStats } from "@andrioid/atproto"; +import { undefined } from "astro:schema"; import Layout from "~astro/layout.astro"; import PageLayout from "~astro/page-layout.astro"; -import { BskyPostList } from "~react/bluesky/post-list"; +import { BskyFeedPostList } from "~react/bluesky/feed-post-list"; const at = Astro.locals.at; const url = new URL(Astro.request.url); -const query = url.searchParams.get("query"); +const query = + url.searchParams.get("query") !== null + ? (url.searchParams.get("query") as string) + : ""; const minscore = url.searchParams.get("minscore") !== null ? Number(url.searchParams.get("minscore")) @@ -14,79 +18,37 @@ const maxscore = url.searchParams.get("maxscore") !== null ? Number(url.searchParams.get("maxscore")) : undefined; -const page = url.searchParams.get("page") - ? Number(url.searchParams.get("page")) +const offset = url.searchParams.get("offset") + ? Number(url.searchParams.get("offset")) : 1; +const limit = 30; +const rkey = url.searchParams.get("rkey") ?? "tech-mod"; const dat = await getAdminStats(at); -const posts = await getModerationPosts(at, { - query: query ?? undefined, - minScore: minscore, - maxScore: maxscore, - page: page, +const feed = feeds.find((f) => f.rkey === rkey); +if (!feed) { + throw new Error("No handler found for selected feed"); +} + +const feedRes = await feed.handler({ + ctx: Astro.locals.at, + actorDid: DEFAULT_FEED_ACTOR, + cursor: offset.toString(), + search: query, }); + +const posts = feedRes.feed; + const nurl = new URL(url); -const nextPageNumber = page + 1; -nurl.searchParams.set("page", `${nextPageNumber}`); +const nextOffset = `${offset + limit - 1}`; +const prevOffset = `${offset ? offset - limit : 0}`; +nurl.searchParams.set("offset", `${nextOffset}`); const nextPage = nurl.toString(); const scoreOptions = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; --- -
-
-
- - - - - - - - - - - -
-
-
{ dat.map((d) => ( @@ -97,13 +59,75 @@ const scoreOptions = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; )) }
- p.postId)} - mayClassify={true} - > +
+
+
+ +
+
+
+ + + + + + - + + + + +
+
+
+
+
Loading
-
+