Restrict graph to tracked commits

This commit is contained in:
Joscha 2023-08-16 00:58:44 +02:00
parent 91e4883137
commit 4d222e971c
5 changed files with 25 additions and 17 deletions

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE metric = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) ORDER BY hash ASC ",
"query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE metric = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) WHERE reachable = 2 ORDER BY hash ASC ",
"describe": {
"columns": [
{
@ -16,5 +16,5 @@
true
]
},
"hash": "c202b6c8e83d2535301e0633404b83a7a7b4b105338833223dd5ab0ebdecfdfd"
"hash": "0d2711c13a7835dd6a6708c2dc81ca15ab3a58a8553a5837351ec63265edb5c2"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT hash, committer_date AS \"time: OffsetDateTime\" FROM commits ORDER BY hash ASC ",
"query": "SELECT hash, committer_date AS \"time: OffsetDateTime\" FROM commits WHERE reachable = 2 ORDER BY hash ASC ",
"describe": {
"columns": [
{
@ -22,5 +22,5 @@
false
]
},
"hash": "3227b67648549c213c6ad34c78842a8d8120d3202f002d293e674cac994adedc"
"hash": "0dc1d000038b42bbbcfe16a11cb8c89a86ba9bb71368a413eb90593f5da166e0"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT parent, child FROM commit_links ORDER BY parent ASC, child ASC ",
"query": "SELECT parent, child FROM commit_links JOIN commits ON hash = parent WHERE reachable = 2 ORDER BY parent ASC, child ASC ",
"describe": {
"columns": [
{
@ -22,5 +22,5 @@
false
]
},
"hash": "eecd95c794db0640d2de01dc644af7e2c6e4ab357710d6a1ee374cad106c166e"
"hash": "4f3c635a7026015f95d20823a25a00870a19f9336c3566b1daeb639f81cb2154"
}

View file

@ -170,6 +170,7 @@ pub async fn get_graph_data(
hash, \
committer_date AS \"time: OffsetDateTime\" \
FROM commits \
WHERE reachable = 2 \
ORDER BY hash ASC \
"
)
@ -185,6 +186,8 @@ pub async fn get_graph_data(
"\
SELECT parent, child \
FROM commit_links \
JOIN commits ON hash = parent \
WHERE reachable = 2 \
ORDER BY parent ASC, child ASC \
"
)
@ -205,9 +208,11 @@ pub async fn get_graph_data(
let mut parents = HashMap::<usize, Vec<usize>>::new();
for (parent, child) in &parent_child_pairs {
let parent_idx = sorted_hash_indices[parent];
let child_idx = sorted_hash_indices[child];
parents.entry(parent_idx).or_default().push(child_idx);
if let Some(parent_idx) = sorted_hash_indices.get(parent) {
if let Some(child_idx) = sorted_hash_indices.get(child) {
parents.entry(*parent_idx).or_default().push(*child_idx);
}
}
}
// Collect times
@ -239,6 +244,7 @@ pub async fn get_graph_data(
SELECT value \
FROM commits \
LEFT JOIN measurements USING (hash) \
WHERE reachable = 2 \
ORDER BY hash ASC \
",
metric,

View file

@ -65,6 +65,7 @@ pub fn sort_topologically(
.map(|hash| (hash.clone(), HashSet::<String>::new()))
.collect::<HashMap<_, _>>();
for (parent, child) in parent_child_pairs {
if parent_child_map.contains_key(parent) && parent_child_map.contains_key(child) {
parent_child_map
.get_mut(parent)
.unwrap()
@ -74,6 +75,7 @@ pub fn sort_topologically(
.unwrap()
.insert(parent.clone());
}
}
// Initialize parentless stack using commit list, in reverse order so that
// the order is right when popping.