aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-08-26 12:01:17 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-08-26 12:01:17 +0200
commite5d8c474f9e3eb542a6a06e95a1ff06a84cea022 (patch)
treef49c82692a90944b5ce6e0edede0e0f21212dd85 /sonar-server/src/main
parent133212f106d8032370e18d4b6f16a52bf5e92206 (diff)
downloadsonarqube-e5d8c474f9e3eb542a6a06e95a1ff06a84cea022.tar.gz
sonarqube-e5d8c474f9e3eb542a6a06e95a1ff06a84cea022.zip
SONAR-2701 Adjustments on TimeMachine widget
- Display only latest snapshot if number_of_versions set to 1 - Fix bug and actually always display oldest snapshot of the selected time frame - Improve CSS rendering - Do not display last column if no sparkline - Do not display metric domain if selected metrics all belong to the same domain (= if there's only one domain to display)
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb32
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css5
2 files changed, 25 insertions, 12 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
index bc1d8d5e9ce..c50e5e54f40 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb
@@ -69,23 +69,35 @@ class Snapshot < ActiveRecord::Base
end
def self.for_timemachine_widget(resource, number_of_versions, options={})
- conditions = ["events.category=? AND events.resource_id=?", "Version", resource.id]
+ snapshot_conditions = ["snapshots.project_id=? AND snapshots.status=? AND snapshots.scope=? AND snapshots.qualifier=?", resource.id, STATUS_PROCESSED, resource.scope, resource.qualifier]
+ event_conditions = ["events.category=? AND events.resource_id=?", "Version", resource.id]
if (options[:from])
- conditions[0] += " AND events.event_date>=?"
- conditions << options[:from]
+ snapshot_conditions[0] += " AND snapshots.created_at>=?"
+ snapshot_conditions << options[:from]
+ event_conditions[0] += " AND events.event_date>=?"
+ event_conditions << options[:from]
end
- events = Event.find(:all, :conditions => conditions, :order => 'events.event_date ASC')
- events_to_display = events
- if number_of_versions < events.size
- events_to_display = [events.first] + events[events.size-number_of_versions+1 .. events.size-1]
+ if number_of_versions == 1
+ # Display only the latest snapshot
+ last_snapshot = Snapshot.find(:last, :conditions => snapshot_conditions, :order => 'snapshots.created_at ASC')
+ return [last_snapshot]
end
+
+ # Look for 1rst snapshot of the period
+ first_snapshot=Snapshot.find(:first, :conditions => snapshot_conditions, :order => 'snapshots.created_at ASC')
+
+ # Look for the number_of_versions-1 last events to display
+ events_to_display = Event.find(:all, :conditions => event_conditions, :order => 'events.event_date ASC').last(number_of_versions-1)
+
+ # And retrieve the wanted snapshots corresponding to the events
sids = []
events_to_display.each() do |event|
- sids << event.snapshot_id
- end
+ sids << event.snapshot_id unless event.snapshot_id == first_snapshot.id
+ end
+ last_snapshots=Snapshot.find(:all, :conditions => ["snapshots.id IN (?)", sids], :include => 'events', :order => 'snapshots.created_at ASC')
- snapshots=Snapshot.find(:all, :conditions => ["snapshots.id IN (?)", sids], :include => 'events', :order => 'snapshots.created_at ASC')
+ return [first_snapshot] + last_snapshots
end
def last?
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index 00f2bfb027f..df92e7de875 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -1793,11 +1793,12 @@ table.matrix tbody td.title {
}
div.widget-matrix {
- overflow:auto;
+ overflow:auto;
}
table.widget-matrix {
font-size: 12px;
+ margin: 1px;
}
table.widget-matrix thead {
@@ -1820,7 +1821,7 @@ table.widget-matrix tbody td.title {
table.widget-matrix tbody td {
border: 1px solid #ddd;
margin: 0;
- padding: 1px 0 1px 10px;
+ padding: 1px 2px 1px 10px;
}