From e6514106da842c1ca66c55714451ba5ce4c35e25 Mon Sep 17 00:00:00 2001 From: Arne Tarara Date: Sun, 23 Jul 2023 14:19:55 +0200 Subject: [PATCH] Added compare feature --- api/api.py | 2 +- frontend/js/timeline.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/api/api.py b/api/api.py index f6ad77850..6a909aad9 100644 --- a/api/api.py +++ b/api/api.py @@ -262,7 +262,7 @@ async def get_timeline_stats(uri: str, branch: str | None = None, filename: str query = f""" SELECT - phase_stats.metric, phase_stats.detail_name, phase_stats.phase, + projects.id, phase_stats.metric, phase_stats.detail_name, phase_stats.phase, phase_stats.value, projects.commit_hash, projects.commit_timestamp FROM projects LEFT JOIN phase_stats ON diff --git a/frontend/js/timeline.js b/frontend/js/timeline.js index ed8cbb011..8e6a25b88 100644 --- a/frontend/js/timeline.js +++ b/frontend/js/timeline.js @@ -37,8 +37,10 @@ $(document).ready( (e) => { let legends = {}; let series = {}; + let pproject_id = null + phase_stats_data.forEach( (data) => { - let [metric_name, detail_name, phase, value, commit_hash, commit_timestamp] = data + let [project_id, metric_name, detail_name, phase, value, commit_hash, commit_timestamp] = data if (series[`${metric_name} - ${detail_name}`] == undefined) { @@ -50,15 +52,12 @@ $(document).ready( (e) => { series[`${metric_name} - ${detail_name}`].notes.push({ commit_timestamp: commit_timestamp, commit_hash: commit_hash, - phase: phase - + phase: phase, + project_id: project_id, + pproject_id: pproject_id, }) - - - - - + pproject_id = project_id }) const chart_instances = []; @@ -86,14 +85,24 @@ $(document).ready( (e) => { options.tooltip = { trigger: 'item', formatter: function (params, ticket, callback) { - console.log(params); - return `${series[params.seriesName].notes[params.dataIndex]}
+ return `${params.seriesName}
+ phase: ${series[params.seriesName].notes[params.dataIndex].phase}
+ value: ${series[params.seriesName].values[params.dataIndex]}
timestamp: ${series[params.seriesName].notes[params.dataIndex].commit_timestamp}
commit_hash: ${series[params.seriesName].notes[params.dataIndex].commit_hash}
+
+ Click to diff measurement with previous `; } }; + chart_instance.on('click', function (params) { + // The params object contains information about the clicked bar + window.open(`/compare.html?ids=${series[params.seriesName].notes[params.dataIndex].project_id},${series[params.seriesName].notes[params.dataIndex].pproject_id}`, '_blank'); + + }); + + chart_instance.setOption(options); chart_instances.push(chart_instance);