-
${stats.count}
-
(${stats.percentage}%)
+ .map(([type, count]) => {
+ const percentage = data.media_stats.media_type_percentages[type];
+ return `
+
+
${type}
+
+ ${count}
+ (${percentage}%)
+
-
- `)
+ `;
+ })
.join('');
document.getElementById('media-distribution').innerHTML = distributionHtml;
diff --git a/main.py b/main.py
index 756d270..16d53ef 100644
--- a/main.py
+++ b/main.py
@@ -153,6 +153,7 @@ class MediaItem(BaseModel):
class MediaStats(BaseModel):
total_media_shared: int
media_by_type: Dict[str, int]
+ media_type_percentages: Dict[str, float]
top_media_sharers: List[UserActivity]
most_reacted_media: List[MediaItem]
@@ -209,8 +210,8 @@ def clean_message(text: str) -> str:
"""Remove Unicode control characters and normalize whitespace."""
return UNICODE_CONTROL_CHARS.sub('', text).strip()
-# Pre-compile pattern for media messages
-MEDIA_PATTERN = re.compile(r'(?:)?\[?(?:\d{2}/\d{2}/\d{4},\s\d{1,2}:\d{2}(?::\d{2})?\s?(?:AM|PM)?\]?\s)?(?:.*?):\s?(?:)?(?:(image|video|GIF|sticker|audio|document) omitted|