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>,
)
| 651 | |
| 652 | /// Create an empty session record (e.g., a fork with no inherited turns). |
| 653 | pub fn index_empty_session( |
| 654 | &mut self, |
| 655 | session_id: &str, |
| 656 | json_path: &str, |
| 657 | view_name: Option<String>, |
| 658 | parent_view: Option<String>, |
| 659 | ) -> PristineResult<()> { |
| 660 | use crate::change::session::SessionRecord; |
| 661 | |
| 662 | let mut sessions = self.txn.open_table(SESSIONS)?; |
| 663 | if sessions.get(session_id)?.is_some() { |
| 664 | return Ok(()); |
| 665 | } |
| 666 | let record = SessionRecord { |
| 667 | session_id: session_id.to_string(), |
| 668 | json_path: json_path.to_string(), |
| 669 | view_name, |
| 670 | parent_view, |
| 671 | first_provenance: None, |
| 672 | latest_provenance: None, |
| 673 | turn_count: 0, |
| 674 | started_at: chrono::Utc::now().timestamp(), |
| 675 | ended_at: None, |
| 676 | }; |
| 677 | let bytes = record.to_bytes(); |
| 678 | sessions.insert(session_id, bytes.as_slice())?; |
| 679 | drop(sessions); |
| 680 | self.emit_session_node(&record) |
| 681 | } |
| 682 | |
| 683 | /// Reconcile lifecycle metadata for a session record. |
| 684 | /// |