Commit 3b977577 authored by Martin Peres's avatar Martin Peres

latency.js: replace hand-coded getweek with d3.time.format

The hand-coded version was generating the wrong output for sundays.
parent 790f78a4
......@@ -38,15 +38,6 @@ function set_url_parameter(param, value) {
}
function pw_test_latency_fetch(project, tests_target, plot_target, weeks, default_test) {
Date.prototype.getWeek = function() {
let date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
var week1 = new Date(date.getFullYear(), 0, 4);
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
function setProgress(data, cur_page) {
let text = "LOADING";
if (data !== null) {
......@@ -94,7 +85,10 @@ function pw_test_latency_fetch(project, tests_target, plot_target, weeks, defaul
json_data.forEach(item =>{
var sdate = new Date(item.event_time);
var elapsedTime = (sdate - new Date(item.parameters.revision_completed)) / (1000*60*60);
var label = `WW${sdate.getUTCFullYear()}'${sdate.getWeek()}.${sdate.getDay()}`
var format = Plotly.d3.time.format("WW%Y'%U.%w");
var label = format(sdate);
if (!pw_latencies[item.parameters.test]) pw_latencies[item.parameters.test] = {};
if (!pw_latencies[item.parameters.test][label]) pw_latencies[item.parameters.test][label] = [];
pw_latencies[item.parameters.test][label].push(elapsedTime)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment