feat: add summary endpoint

This commit is contained in:
2026-01-31 15:46:53 +00:00
parent 445cfbdf96
commit 2789bbeb14
2 changed files with 31 additions and 3 deletions

View File

@@ -88,7 +88,7 @@ class StatGen:
self.df
.groupby('date')
.size()
.reset_index(name='posts_count')
.reset_index(name='event_count')
)
def filter_events(self, search_query: str) -> pd.DataFrame:
@@ -96,4 +96,18 @@ class StatGen:
return self.df
def reset_dataset(self) -> None:
self.df = self.original_df.copy(deep=True)
self.df = self.original_df.copy(deep=True)
def get_summary(self) -> dict:
return {
"total_events": int(len(self.df)),
"total_posts": int((self.df["type"] == "post").sum()),
"total_comments": int((self.df["type"] == "comment").sum()),
"unique_users": int(self.df["author"].nunique()),
"time_range": {
"start": int(self.df["dt"].min().timestamp()),
"end": int(self.df["dt"].max().timestamp())
}
}