BlueGit

ict rusty-teams

Files

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

demo_recap.rs

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