diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-09-19 17:52:06 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-09-19 17:52:06 +0200 |
commit | 2953b754d25118a9e065683c39faa4e5dc1dcca0 (patch) | |
tree | 3f5ca6e007497904f51e066ddaeba6f7fb051315 | |
parent | 0ce576e728ed719f2b89bace3eac6b711209f704 (diff) | |
download | sonarqube-2953b754d25118a9e065683c39faa4e5dc1dcca0.tar.gz sonarqube-2953b754d25118a9e065683c39faa4e5dc1dcca0.zip |
SONAR-2074 Fix bug on Timeline widget when metric values are missing
Indeed, Protovis can't display multiple arrays if they have
disjoined X-axis value sets.
-rw-r--r-- | plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb index 253db4ade60..8926d741323 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb @@ -23,7 +23,14 @@ if from_date options[:from] = from_date end + metric_count_per_snapshot_id = {} TrendsChart.time_machine_measures(@resource, metric_data_map.keys, options).each() do |trend_item| + sid = trend_item["sid"] + if metric_count_per_snapshot_id[sid] + metric_count_per_snapshot_id[sid] += 1 + else + metric_count_per_snapshot_id[sid] = 1 + end metric_data_map[trend_item["metric_id"].to_i] << {:date => trend_item["created_at"], :value => trend_item["value"], :sid => trend_item["sid"]} end @@ -31,35 +38,39 @@ js_data = "[" js_snapshots = "[" js_metrics = "[" + total_number_of_metrics = metric_name_map.keys.size() metric_data_map.keys.each_with_index() do |metric_id, index| unless metric_data_map[metric_id].empty? js_metrics += "\"" + metric_name_map[metric_id] + "\"," js_data += "[" metric_data_map[metric_id].each() do |metric_data| - m_date = Time.parse(metric_data[:date]) - js_data += "{x:d(" - js_data += m_date.year.to_s - js_data += "," - # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) - js_data += (m_date.month - 1).to_s - js_data += "," - js_data += m_date.day.to_s - js_data += "," - js_data += m_date.hour.to_s - js_data += "," - js_data += m_date.min.to_s - js_data += "," - js_data += m_date.sec.to_s - js_data += "),y:" - js_data += sprintf( "%0.02f", metric_data[:value]) - js_data += "}," - if index == 0 - # we fill the js_snapshots array (no need to do this more than once) - js_snapshots += "{sid:" - js_snapshots += metric_data[:sid].to_s - js_snapshots += ",d:\"" - js_snapshots += l m_date, :format => :long - js_snapshots += "\"}," + # for every metric value, we need to check that the corresponding snapshot has values for each metric (if not, Protovis won't be able to display) + if metric_count_per_snapshot_id[metric_data[:sid]]==total_number_of_metrics + m_date = Time.parse(metric_data[:date]) + js_data += "{x:d(" + js_data += m_date.year.to_s + js_data += "," + # Need to decrease by 1 the month as the JS Date object start months at 0 (= January) + js_data += (m_date.month - 1).to_s + js_data += "," + js_data += m_date.day.to_s + js_data += "," + js_data += m_date.hour.to_s + js_data += "," + js_data += m_date.min.to_s + js_data += "," + js_data += m_date.sec.to_s + js_data += "),y:" + js_data += sprintf( "%0.02f", metric_data[:value]) + js_data += "}," + if index == 0 + # we fill the js_snapshots array (no need to do this more than once) + js_snapshots += "{sid:" + js_snapshots += metric_data[:sid].to_s + js_snapshots += ",d:\"" + js_snapshots += human_short_date m_date + js_snapshots += "\"}," + end end end js_data = js_data.chomp(',') + "]," |