tempo_cli/models/
git_branch.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct GitBranch {
6 pub id: Option<i64>,
7 pub project_id: i64,
8 pub branch_name: String,
9 pub first_seen: DateTime<Utc>,
10 pub last_seen: DateTime<Utc>,
11 pub total_time_seconds: i64,
12}
13
14impl GitBranch {
15 pub fn new(project_id: i64, branch_name: String) -> Self {
16 let now = Utc::now();
17 Self {
18 id: None,
19 project_id,
20 branch_name,
21 first_seen: now,
22 last_seen: now,
23 total_time_seconds: 0,
24 }
25 }
26
27 pub fn update_time(&mut self, seconds: i64) {
28 self.total_time_seconds += seconds;
29 self.last_seen = Utc::now();
30 }
31
32 pub fn total_hours(&self) -> f64 {
33 self.total_time_seconds as f64 / 3600.0
34 }
35}