Skip to content

Commit

Permalink
Fix archive graph not keeping node props (Pometry#1469)
Browse files Browse the repository at this point in the history
* fix archive graph not keeping node props

* save graphs
  • Loading branch information
ricopinazo authored Jan 24, 2024
1 parent 3e8185f commit 44295d5
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions raphtory-graphql/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,34 +333,17 @@ impl Mut {
parent_graph_name: String,
is_archive: u8,
) -> Result<bool> {
let mut data = ctx.data_unchecked::<Data>().graphs.write();

let data = ctx.data_unchecked::<Data>().graphs.write();
let subgraph = data.get(&graph_name).ok_or("Graph not found")?;
subgraph.update_constant_properties([("isArchive", Prop::U8(is_archive))])?;

let path = subgraph
.properties()
.constant()
.get("path")
.ok_or("Path is missing")?
.to_string();

let parent_graph = data.get(&parent_graph_name).ok_or("Graph not found")?;
let new_subgraph = parent_graph
.subgraph(subgraph.nodes().iter().map(|v| v.name()).collect_vec())
.materialize()?;

let static_props_without_isactive: Vec<(ArcStr, Prop)> = subgraph
.properties()
.into_iter()
.filter(|(a, _)| a != "isArchive")
.collect_vec();
new_subgraph.update_constant_properties(static_props_without_isactive)?;
new_subgraph.update_constant_properties([("isArchive", Prop::U8(is_archive))])?;
new_subgraph.save_to_file(path)?;

let gi: IndexedGraph<MaterializedGraph> = new_subgraph.into();

data.insert(graph_name, gi);
subgraph.save_to_file(path)?;

Ok(true)
}
Expand Down

0 comments on commit 44295d5

Please sign in to comment.