Python/FastAPI backend with PostgreSQL for collecting Reddit data via public .json endpoints. React/Vite dashboard for analytics. Docker Compose setup with API and worker services connecting to shared PostgreSQL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
992 B
Python
55 lines
992 B
Python
from datetime import datetime, date
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class EngagementPoint(BaseModel):
|
|
period: str
|
|
posts: int
|
|
comments: int
|
|
avg_score: float
|
|
|
|
|
|
class TopPost(BaseModel):
|
|
id: int
|
|
title: str
|
|
score: int
|
|
num_comments: int
|
|
author_name: str | None
|
|
subreddit_name: str
|
|
created_utc: datetime
|
|
permalink: str | None
|
|
|
|
|
|
class TopAuthor(BaseModel):
|
|
id: int
|
|
username: str
|
|
post_count: int
|
|
comment_count: int
|
|
total_activity: int
|
|
|
|
|
|
class SubredditSummary(BaseModel):
|
|
subreddit_id: int
|
|
subreddit_name: str
|
|
total_posts: int
|
|
total_comments: int
|
|
avg_score: float
|
|
top_flair: str | None
|
|
|
|
|
|
class FlairCount(BaseModel):
|
|
flair: str | None
|
|
count: int
|
|
|
|
|
|
class DigestResponse(BaseModel):
|
|
id: int
|
|
subreddit_id: int
|
|
subreddit_name: str | None = None
|
|
digest_date: date
|
|
content: str
|
|
metadata_: dict | None = None
|
|
generated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|