src/heatmap.cpp

changeset 81
1ff88eb9555c
parent 80
fa5f493adfb5
--- a/src/heatmap.cpp	Fri Feb 27 14:38:01 2026 +0100
+++ b/src/heatmap.cpp	Thu Mar 12 12:00:50 2026 +0100
@@ -32,7 +32,6 @@
 
 void fm::heatmap::add(const settings &settings, const std::string &log) {
     using std::string_view_literals::operator ""sv;
-    const std::string repo_key = m_separate ? m_current_repo : "All Repositories";
 
     for (auto line: std::views::split(log, "\n"sv)) {
         if (line.empty()) continue;
@@ -59,15 +58,20 @@
         std::from_chars(date_parts[0].begin(), date_parts[0].end(), year);
         std::from_chars(date_parts[1].begin(), date_parts[1].end(), month);
         std::from_chars(date_parts[2].begin(), date_parts[2].end(), day);
-        auto &[summaries, tags] =
-                m_heatmap[repo_key][author][chrono::year_month_day{
-                    chrono::year{year}, chrono::month{month}, chrono::day{day}
-                }];
-        summaries[m_current_repo].emplace_back(hash_view, summary_view);
-        // special case: if the (only) tag is "tip", we do not add it
-        if (!tags_view.empty() && tags_view != "tip") {
-            tags[m_current_repo].emplace_back(hash_view, tags_view);
-        }
+        const auto ymd = chrono::year_month_day{
+            chrono::year{year}, chrono::month{month}, chrono::day{day}
+        };
+
+        auto add_info = [this, hash_view, summary_view, tags_view] (commits & commit_info) {
+            commit_info.summaries[m_current_repo].emplace_back(hash_view, summary_view);
+            // special case: if the (only) tag is "tip", we do not add it
+            if (!tags_view.empty() && tags_view != "tip") {
+                commit_info.tags[m_current_repo].emplace_back(hash_view, tags_view);
+            }
+        };
+
+        add_info(m_heatmap[m_current_repo][author][ymd]);
+        add_info(m_aggregated_heatmap[aggregated_repo_label][author][ymd]);
     }
 }
 
@@ -77,7 +81,8 @@
     chrono::year year
 ) const {
     std::array<commit_summary, 12> result{};
-    for (auto &&[ymd, commits]: m_heatmap.at(repo).at(author)) {
+    for (const auto &heatmap_data = repo == aggregated_repo_label ? m_aggregated_heatmap : m_heatmap;
+            auto &&[ymd, commits]: heatmap_data.at(repo).at(author)) {
         if (ymd.year() != year) continue;
         commit_summary &cs = result[static_cast<unsigned int>(ymd.month()) - 1];
         for (auto &&[reponame, summaries]: commits.summaries) {

mercurial