story-research-zapwall/lib/seriesAggregation.ts
2025-12-23 02:20:57 +01:00

21 lines
735 B
TypeScript

import { aggregateZapSats } from './zapAggregation'
export interface SeriesAggregates {
sponsoring: number
purchases: number
reviewTips: number
}
export async function getSeriesAggregates(params: {
authorPubkey: string
seriesId: string
}): Promise<SeriesAggregates> {
const [sponsoring, purchases, reviewTips] = await Promise.all([
aggregateZapSats({ authorPubkey: params.authorPubkey, seriesId: params.seriesId, kindType: 'sponsoring' }),
aggregateZapSats({ authorPubkey: params.authorPubkey, seriesId: params.seriesId, kindType: 'purchase' }),
aggregateZapSats({ authorPubkey: params.authorPubkey, seriesId: params.seriesId, kindType: 'review_tip' }),
])
return { sponsoring, purchases, reviewTips }
}