MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_view_info

Method get_view_info

atomic-repository/src/repository/views.rs:714–762  ·  view source on GitHub ↗

Get information about a view. Returns the view's metadata including its Merkle state and change count. # Arguments `name` - The name of the view to query # Returns A `ViewInfo` struct with the view's metadata, or an error if the view doesn't exist.

(&self, name: &str)

Source from the content-addressed store, hash-verified

712 /// A `ViewInfo` struct with the view's metadata, or an error if the view
713 /// doesn't exist.
714 pub fn get_view_info(&self, name: &str) -> Result<ViewInfo, RepositoryError> {
715 let txn = self
716 .pristine
717 .read_txn()
718 .map_err(|e| RepositoryError::Database(e.to_string()))?;
719
720 let view = txn
721 .get_view(name)
722 .map_err(|e| RepositoryError::Database(e.to_string()))?
723 .ok_or_else(|| RepositoryError::ViewNotFound {
724 name: name.to_string(),
725 })?;
726
727 // Resolve parent name and compute own/inherited change counts by
728 // actual graph membership rather than by assuming the own log is a
729 // superset of the parent (which only holds for `create_view_from`
730 // drafts, not for record- or split-created drafts).
731 let membership = view_membership(&txn, &view)?;
732 let (parent_name, own_change_count, inherited_change_count) = match view.parent {
733 Some(parent_id) => {
734 let parent = txn
735 .get_view_by_id(parent_id)
736 .map_err(|e| RepositoryError::Database(e.to_string()))?
737 .ok_or_else(|| {
738 RepositoryError::Database(format!(
739 "view '{}' ({}) references missing parent {}",
740 view.name, view.id, parent_id
741 ))
742 })?;
743 let inherited = view_membership(&txn, &parent)?;
744 let own = membership
745 .iter()
746 .filter(|change_id| !inherited.contains(**change_id))
747 .count() as u64;
748 (Some(parent.name), own, inherited.len() as u64)
749 }
750 None => (None, membership.len() as u64, 0),
751 };
752
753 Ok(ViewInfo {
754 name: view.name.clone(),
755 state: view.state,
756 change_count: view.change_count,
757 own_change_count,
758 inherited_change_count,
759 scope: view.kind,
760 parent_name,
761 })
762 }
763
764 /// Create a new Draft view parented on an explicit named parent.
765 ///

Callers 15

runMethod · 0.80
run_showMethod · 0.80
print_forensic_statusFunction · 0.80
run_promote_to_parentFunction · 0.80
resolve_referenceMethod · 0.80
display_dry_runMethod · 0.80
runMethod · 0.80
resolve_conflict_exportFunction · 0.80
resolve_head_policyFunction · 0.80

Calls 9

view_membershipFunction · 0.85
read_txnMethod · 0.80
get_viewMethod · 0.45
get_view_by_idMethod · 0.45
countMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45