BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-base / src / demo_recap.rs

demo_recap.rs

chore: cargo fmt the workspace
metis Daniel Däschle · pushed by metis · 2 weeks ago
a6592765 History
demo_recap.rs 3.5 KiB Download Raw
1use chatsvc::{Attendance, AttendanceRecord, Occurrence, RecordingDetails, TranscriptTurn};
2use chrono::{DateTime, Duration, Utc};
3
4pub const DEMO_RECAP_CHAT: &str = "demo-chat-meeting-standup";
5const ORGANIZER_ID: &str = "demo-me";
6const OCCURRENCE_DAYS: [i64; 3] = [0, 1, 2];
7const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings/standup";
8const SHORT_EXPIRY_DAYS: i64 = 5;
9const LONG_EXPIRY_DAYS: i64 = 58;
10
11const LINES: [(&str, f64, &str); 7] = [
12 (
13 "Jonas Ortega",
14 4.0,
15 "Morning everyone. Quick round, then we are done in ten.",
16 ),
17 (
18 "Priya Nair",
19 21.0,
20 "Yesterday I finished the export flow. Today I pick up the retry logic.",
21 ),
22 (
23 "Mara Lindqvist",
24 49.0,
25 "I am blocked on the staging certificate. Can someone ping IT?",
26 ),
27 (
28 "Jonas Ortega",
29 63.0,
30 "I will ping them right after this. Anything else on the release?",
31 ),
32 (
33 "Tobias Klein",
34 88.0,
35 "The release notes are drafted, I need a second pair of eyes.",
36 ),
37 ("Priya Nair", 104.0, "I can review them before lunch."),
38 (
39 "Jonas Ortega",
40 121.0,
41 "Great. Thanks all, see you tomorrow.",
42 ),
43];
44
45pub fn occurrences(conversation_id: &str, now: DateTime<Utc>) -> Vec<Occurrence> {
46 if conversation_id != DEMO_RECAP_CHAT {
47 return Vec::new();
48 }
49 OCCURRENCE_DAYS
50 .into_iter()
51 .map(|days_ago| Occurrence {
52 message_id: format!("demo-recap-{days_ago}"),
53 started_at: Some(now - Duration::days(days_ago) - Duration::hours(1)),
54 recording_url: format!("{DEMO_RECORDING_URL}-{days_ago}.mp4"),
55 recording_name: Some(format!("Daily standup-{days_ago}-Meeting Recording.mp4")),
56 duration_seconds: Some(920 + days_ago as u64 * 65),
57 organizer_id: Some(ORGANIZER_ID.to_owned()),
58 audio_only: false,
59 })
60 .collect()
61}
62
63pub fn details(occurrence: &Occurrence, now: DateTime<Utc>) -> RecordingDetails {
64 let latest = occurrence.message_id.ends_with('0');
65 RecordingDetails {
66 item_url: occurrence.recording_url.clone(),
67 audio_only: occurrence.message_id.ends_with('2'),
68 transcript_only: false,
69 duration_seconds: occurrence.duration_seconds,
70 expires_at: Some(
71 now + Duration::days(if latest {
72 LONG_EXPIRY_DAYS
73 } else {
74 SHORT_EXPIRY_DAYS
75 }) - Duration::minutes(1),
76 ),
77 transcript_id: Some("demo-transcript".to_owned()),
78 }
79}
80
81pub fn transcript() -> Vec<TranscriptTurn> {
82 LINES
83 .iter()
84 .map(|(speaker, start_seconds, text)| TranscriptTurn {
85 speaker: (*speaker).to_owned(),
86 start_seconds: *start_seconds,
87 end_seconds: start_seconds + 12.0,
88 text: (*text).to_owned(),
89 })
90 .collect()
91}
92
93pub fn attendance(now: DateTime<Utc>) -> Attendance {
94 let start = now - Duration::hours(1);
95 let record = |name: &str, joined: i64, left: i64| AttendanceRecord {
96 name: name.to_owned(),
97 joined_at: Some(start + Duration::minutes(joined)),
98 left_at: Some(start + Duration::minutes(left)),
99 duration_seconds: ((left - joined) * 60) as u64,
100 };
101 Attendance::Report(vec![
102 record("Jonas Ortega", 0, 16),
103 record("Priya Nair", 1, 16),
104 record("Mara Lindqvist", 2, 15),
105 record("Tobias Klein", 5, 12),
106 ])
107}
108
109pub const DEMO_FILE_BYTES: &[u8] = b"Rusty Teams demo file\n";