Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/engine/src/cmd/sharing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,13 +1418,18 @@ fn link_chart(s: &Session, rel: Option<&str>) -> Result<(String, Option<String>)
// out; one already in the chart may still be linked.
// Up to 200 links drawn from it: destinations the chart has no room for don't count
// toward them, so a later one it can draw still is.
let mut a = index.get(&(om, o.id, orow)).copied();
let origin = (om, o.id, orow);
let mut a = index.get(&origin).copied();
if a.is_none() && nodes.len() >= MAX_NODES {
continue;
}
let mut drawn_here = 0;
for &drow in drows {
if drawn_here >= MAX_FEATURE_LINKS || links.len() >= MAX_LINKS {
break;
}
let new = usize::from(a.is_none()) + usize::from(!index.contains_key(&(dm, d.id, drow)));
let destination = (dm, d.id, drow);
let new = usize::from(a.is_none()) + usize::from(destination != origin && !index.contains_key(&destination));
if nodes.len() + new > MAX_NODES {
continue;
}
Expand Down
11 changes: 11 additions & 0 deletions crates/engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12660,6 +12660,17 @@ fn a_link_chart_says_what_its_limits_leave_out() {
let shows = "300 of the 301 related features and 20000 of the 20200 links";
assert_eq!(said(&s, mark, "Mesh"), [format!("Mesh: the link chart shows {shows}; {limits}")]);
assert!(html.contains(&format!("Shows {shows}.")));
// A self-link needs one node, including the last available slot. Counting its endpoints
// twice would stop at 2,999 even though all 3,000 features and links fit.
let keys: Vec<String> = (0..3000).map(|i| format!("self{i}")).collect();
add(&mut s, "self.csv", &keys);
s.run("data.relate", &json!({"name": "Self", "origin": "self", "originKey": "key", "destination": "self", "destinationKey": "key"}))
.unwrap();
let mark = s.notice_mark();
s.run("share.linkChart", &json!({"relationship": "Self"})).unwrap();
let (links, nodes, html) = drawn("Self");
assert_eq!((links, nodes), (3000, 3000));
assert!(said(&s, mark, "Self").is_empty() && !html.contains("Shows "));
let _ = std::fs::remove_dir_all(dir);
}

Expand Down
Loading