Locations in score.

This commit is contained in:
Neil 2023-05-14 23:18:59 -07:00
parent 7f8c7710e0
commit cb6e0ebab4
1 changed files with 15 additions and 3 deletions

View File

@ -1071,11 +1071,23 @@ void scan_score_graph(struct scan *const scan) {
line = linemap_tree_key(&it);
assert(*linemap_tree_value(&it) < scan->scores.array.size);
score = scan->scores.array.data + *linemap_tree_value(&it);
/* Get a place. */
struct linemap_tree_iterator place_it
= linemap_tree_less(&scan->places.dates, line);
struct pair place_name;
if(!linemap_tree_has_element(&place_it)) {
place_name = (struct pair){ 0, 0 };
} else {
assert(*linemap_tree_value(&place_it) < scan->places.array.size);
place_name
= scan->places.array.data[*linemap_tree_value(&place_it)].name;
}
char datestr[12];
date32_to_string(line.date, &datestr);
score->score++;
printf("%s, %.*s, %u\n", datestr,
(int)(score->key.b - score->key.a), score->key.a, score->score);
score->score++; /* Keep track of the score per key. */
printf("%s, %.*s, %u, %.*s\n", datestr,
(int)(score->key.b - score->key.a), score->key.a, score->score,
(int)(place_name.b - place_name.a), place_name.a);
}
printf("EOD\n"
"# theozh https://stackoverflow.com/a/75466214/2472827\n"