From 302eb33b1b84a4ac76f859f74d9261419b10c719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Tue, 22 Feb 2022 08:19:51 +0100 Subject: [PATCH] fix: branches chart (resolve #322) --- scripts/sample_data.py | 3 +++ static/assets/js/summary.js | 6 +++--- version.txt | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/sample_data.py b/scripts/sample_data.py index 4ff9ef1..30a73b4 100644 --- a/scripts/sample_data.py +++ b/scripts/sample_data.py @@ -21,6 +21,7 @@ LANGUAGES = { 'PHP': 'php', 'Blade': 'blade.php' } +BRANCHES = ['master', 'feature-1', 'feature-2'] class Heartbeat: @@ -65,6 +66,7 @@ def generate_data(n: int, n_projects: int = 5, n_past_hours: int = 24) -> List[H p: str = random.choice(projects) l: str = random.choice(languages) f: str = randomword(random.randint(2, 8)) + b: str = random.choice(BRANCHES) delta: timedelta = timedelta( hours=random.randint(0, n_past_hours - 1), minutes=random.randint(0, 59), @@ -77,6 +79,7 @@ def generate_data(n: int, n_projects: int = 5, n_past_hours: int = 24) -> List[H entity=f'/home/me/dev/{p}/{f}.{LANGUAGES[l]}', project=p, language=l, + branch=b, time=(now - delta).timestamp() )) diff --git a/static/assets/js/summary.js b/static/assets/js/summary.js index d4386fd..b08f959 100644 --- a/static/assets/js/summary.js +++ b/static/assets/js/summary.js @@ -331,13 +331,13 @@ function draw(subselection) { }) : null - let branchChart = branchesCanvas && !branchesCanvas.classList.contains('hidden') && shouldUpdate(0) + let branchChart = branchesCanvas && !branchesCanvas.classList.contains('hidden') && shouldUpdate(6) ? new Chart(branchesCanvas.getContext('2d'), { type: "bar", data: { datasets: [{ data: wakapiData.branches - .slice(0, Math.min(showTopN[0], wakapiData.branches.length)) + .slice(0, Math.min(showTopN[6], wakapiData.branches.length)) .map(p => parseInt(p.total)), backgroundColor: wakapiData.branches.map((p, i) => { const c = hexToRgb(getColor(p.key, i % baseColors.length)) @@ -349,7 +349,7 @@ function draw(subselection) { }), }], labels: wakapiData.branches - .slice(0, Math.min(showTopN[0], wakapiData.branches.length)) + .slice(0, Math.min(showTopN[6], wakapiData.branches.length)) .map(p => p.key) }, options: { diff --git a/version.txt b/version.txt index fae692e..7e541ae 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.2.1 \ No newline at end of file +2.2.2 \ No newline at end of file