forked from
parakeet.at/parakeet
Rust AppView - highly experimental!
1//! Statistics Value Objects
2
3use crate::domain::entities::Post;
4
5/// Post engagement statistics
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct PostStats {
8 pub likes: i32,
9 pub replies: i32,
10 pub reposts: i32,
11 pub quotes: i32,
12}
13
14impl PostStats {
15 /// Create stats from a Post entity
16 pub fn from_post(post: &Post) -> Self {
17 Self {
18 likes: post.like_count,
19 replies: post.reply_count,
20 reposts: post.repost_count,
21 quotes: post.quote_count,
22 }
23 }
24
25 /// Total engagement count
26 pub fn total_engagement(&self) -> i32 {
27 self.likes + self.replies + self.reposts + self.quotes
28 }
29}
30
31/// Actor profile statistics
32#[derive(Debug, Clone, Copy, PartialEq)]
33pub struct ProfileStats {
34 pub followers: i32,
35 pub following: i32,
36 pub posts: i32,
37 pub lists: i32,
38}
39
40impl ProfileStats {
41 /// Create empty stats
42 pub fn empty() -> Self {
43 Self {
44 followers: 0,
45 following: 0,
46 posts: 0,
47 lists: 0,
48 }
49 }
50}