Create an empty session record (e.g., a fork with no inherited turns).
(
&mut self,
session_id: &str,
json_path: &str,
view_name: Option<String>,
parent_view: Option<String>,
)
| 746 | |
| 747 | /// Create an empty session record (e.g., a fork with no inherited turns). |
| 748 | pub fn index_empty_session( |
| 749 | &mut self, |
| 750 | session_id: &str, |
| 751 | json_path: &str, |
| 752 | view_name: Option<String>, |
| 753 | parent_view: Option<String>, |
| 754 | ) -> PristineResult<()> { |
| 755 | use crate::change::session::SessionRecord; |
| 756 | |
| 757 | let mut sessions = self.txn.open_table(SESSIONS)?; |
| 758 | if sessions.get(session_id)?.is_some() { |
| 759 | return Ok(()); |
| 760 | } |
| 761 | let record = SessionRecord { |
| 762 | session_id: session_id.to_string(), |
| 763 | json_path: json_path.to_string(), |
| 764 | view_name, |
| 765 | parent_view, |
| 766 | first_provenance: None, |
| 767 | latest_provenance: None, |
| 768 | turn_count: 0, |
| 769 | started_at: chrono::Utc::now().timestamp(), |
| 770 | ended_at: None, |
| 771 | }; |
| 772 | let bytes = record.to_bytes(); |
| 773 | sessions.insert(session_id, bytes.as_slice())?; |
| 774 | drop(sessions); |
| 775 | self.emit_session_node(&record) |
| 776 | } |
| 777 | |
| 778 | /// Reconcile lifecycle metadata for a session record. |
| 779 | /// |