Skip to content

Commit

Permalink
Added compare feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Jul 24, 2023
1 parent 7a94ca3 commit e651410
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 19 additions & 10 deletions frontend/js/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = [];
Expand Down Expand Up @@ -86,14 +85,24 @@ $(document).ready( (e) => {
options.tooltip = {
trigger: 'item',
formatter: function (params, ticket, callback) {
console.log(params);
return `<strong>${series[params.seriesName].notes[params.dataIndex]}</strong><br>
return `<strong>${params.seriesName}</strong><br>
phase: ${series[params.seriesName].notes[params.dataIndex].phase}<br>
value: ${series[params.seriesName].values[params.dataIndex]}<br>
timestamp: ${series[params.seriesName].notes[params.dataIndex].commit_timestamp}<br>
commit_hash: ${series[params.seriesName].notes[params.dataIndex].commit_hash}<br>
<br>
<i>Click to diff measurement with previous</i>
`;
}
};

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);

Expand Down

0 comments on commit e651410

Please sign in to comment.