Latest turn time, or the session end/start time if it has no turns. Handles current milliseconds and historical seconds without changing them.
(
&self,
turns: &[SessionTurn],
)
| 659 | /// Latest turn time, or the session end/start time if it has no turns. |
| 660 | /// Handles current milliseconds and historical seconds without changing them. |
| 661 | pub fn activity_datetime( |
| 662 | &self, |
| 663 | turns: &[SessionTurn], |
| 664 | ) -> Option<chrono::DateTime<chrono::Utc>> { |
| 665 | let timestamp = turns |
| 666 | .last() |
| 667 | .map(|turn| turn.timestamp) |
| 668 | .or(self.ended_at) |
| 669 | .unwrap_or(self.started_at); |
| 670 | crate::types::timestamp::epoch_datetime(timestamp) |
| 671 | } |
| 672 | |
| 673 | pub fn to_bytes(&self) -> Vec<u8> { |
| 674 | postcard::to_allocvec(self).expect("SessionRecord serialization") |
no test coverage detected