record-daemon: add record raw events, subscribe lp change events
record-daemon / Build, check and test (push) Successful in 2m0s

This commit is contained in:
vhaudiquet committed 2026-03-27 22:25:24 +01:00
1 parent aa53a84a46
commit b64937601a
8 files changed
+401 -30

No files matched your search

+26
View File
@@ -89,6 +89,31 @@ impl Timeline {
event_type: event_type_name(&event),
description: event.description(),
event,
raw_data: None,
uri: None,
};
self.events.push(timestamped);
}
/// Add an event to the timeline with raw data.
pub fn add_event_with_raw(
&mut self,
event: GameEvent,
video_timestamp: Duration,
game_timestamp: Option<Duration>,
raw_data: serde_json::Value,
uri: String,
) {
let timestamped = TimestampedEvent {
video_timestamp,
game_timestamp,
timestamp: Utc::now(),
event_type: event_type_name(&event),
description: event.description(),
event,
raw_data: Some(raw_data),
uri: Some(uri),
};
self.events.push(timestamped);
@@ -176,6 +201,7 @@ fn event_type_name(event: &GameEvent) -> String {
GameEvent::StatsUpdate(_) => "stats_update",
GameEvent::GameEnd(_) => "game_end",
GameEvent::PhaseChange(_) => "phase_change",
GameEvent::LpChange(_) => "lp_change",
GameEvent::Unknown => "unknown",
}
.to_string()
+7 -1
View File
@@ -23,12 +23,18 @@ pub struct TimestampedEvent {
pub game_timestamp: Option<Duration>,
/// Real-world timestamp.
pub timestamp: DateTime<Utc>,
/// Event type name.
/// Event type name (derived from URI).
pub event_type: String,
/// Human-readable description.
pub description: String,
/// The actual event data.
pub event: GameEvent,
/// Raw JSON data from the API (for flexibility).
#[serde(default)]
pub raw_data: Option<serde_json::Value>,
/// URI of the endpoint that triggered this event.
#[serde(default)]
pub uri: Option<String>,
}
/// Metadata for a recording.