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