Making the outputs a bit more organized, adding some more stats to them

This commit is contained in:
2025-12-30 19:52:34 -05:00
parent 9a8144af68
commit 6e32e3ec54
4 changed files with 39 additions and 17 deletions

View File

@@ -59,22 +59,32 @@ class StatsModel:
return total
def calculate_total_original_post_notes_by_month_and_year(self) -> Dict[str, int]:
date_map: Dict[str, int] = {}
date_map: Dict[str, Any] = {}
date_map = defaultdict(lambda: {'note_count': 0,
'post_count': 0},
date_map)
for post_key in self.original_post_map:
post = self.original_post_map[post_key]
# Format is like 2025-12-28 20:00:34 GMT
post_date: datetime = datetime.strptime(
post['date'], '%Y-%m-%d %H:%M:%S %Z')
post_date_key = f"{post_date.year}-{post_date.month:02}"
if post_date_key in date_map:
date_map[post_date_key] += post['note_count']
else:
date_map[post_date_key] = post['note_count']
sts = date_map[post_date_key]
sts['year_month'] = post_date_key
sts['post_count'] += 1
sts['note_count'] += post['note_count']
for date in date_map:
sts = date_map[date]
post_count = sts['post_count']
note_count = sts['note_count']
sts['notes_to_posts_ratio'] = note_count / post_count
return date_map
def determine_most_popular_tags(self) -> List[Dict[str, Any]]:
tag_dict: Dict[str, Any] = {}
tag_dict = defaultdict(lambda : {'note_count': 0,
tag_dict = defaultdict(lambda: {'note_count': 0,
'post_count': 0},
tag_dict)
for post_key in self.original_post_map: