From 29fe34500a32ff0f1a02c02523950f3042c1386a Mon Sep 17 00:00:00 2001 From: Michael-Andrew Keays Date: Sun, 15 Dec 2024 16:08:05 -0500 Subject: [PATCH] Add poll answer stats to feed aggregator --- packages/bsky/proto/bsky.proto | 6 ++++++ packages/bsky/src/hydration/feed.ts | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/bsky/proto/bsky.proto b/packages/bsky/proto/bsky.proto index 699b9fe673f..5b4e106fb7d 100644 --- a/packages/bsky/proto/bsky.proto +++ b/packages/bsky/proto/bsky.proto @@ -278,11 +278,17 @@ message GetInteractionCountsRequest { repeated RecordRef refs = 1; } +message PollAnswerCount { + repeated int32 count = 3; +} + message GetInteractionCountsResponse { repeated int32 likes = 1; repeated int32 reposts = 2; repeated int32 replies = 3; repeated int32 quotes = 4; + repeated int32 poll_answer_count = 5; + repeated PollAnswerCount poll_answers = 6; } message GetCountsForUsersRequest { diff --git a/packages/bsky/src/hydration/feed.ts b/packages/bsky/src/hydration/feed.ts index 61623ad4173..9f2b4c5dc9d 100644 --- a/packages/bsky/src/hydration/feed.ts +++ b/packages/bsky/src/hydration/feed.ts @@ -1,6 +1,7 @@ import { DataPlaneClient } from '../data-plane/client' import { Record as PostRecord } from '../lexicon/types/app/bsky/feed/post' import { Record as LikeRecord } from '../lexicon/types/app/bsky/feed/like' +import { Record as PollAnswerRecord } from '../lexicon/types/app/bsky/feed/pollAnswer' import { Record as RepostRecord } from '../lexicon/types/app/bsky/feed/repost' import { Record as FeedGenRecord } from '../lexicon/types/app/bsky/feed/generator' import { Record as ThreadgateRecord } from '../lexicon/types/app/bsky/feed/threadgate' @@ -37,6 +38,8 @@ export type PostAgg = { replies: number reposts: number quotes: number + pollAnswerCount: number + pollAnswers: number[] } export type PostAggs = HydrationMap @@ -47,6 +50,9 @@ export type Likes = HydrationMap export type Repost = RecordInfo export type Reposts = HydrationMap +export type PollAnswer = RecordInfo +export type PollAnswers = HydrationMap + export type FeedGenAgg = { likes: number } @@ -166,6 +172,8 @@ export class FeedHydrator { reposts: counts.reposts[i] ?? 0, replies: counts.replies[i] ?? 0, quotes: counts.quotes[i] ?? 0, + pollAnswerCount: counts.pollAnswerCount[i] ?? 0, + pollAnswers: counts.pollAnswers[i]?.count ?? [], }) }, new HydrationMap()) }