aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/models
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-02-20 10:35:51 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-02-20 10:36:20 +0100
commit1b0a3a26064a45bcd9e2e06c69ea6fc5e49a9939 (patch)
tree21286b9e8343a15667d8abf62ed887accf1495ac /sonar-server/src/main/webapp/WEB-INF/app/models
parent8143b2c18b7fa996b8ddc8e45db5372481408197 (diff)
downloadsonarqube-1b0a3a26064a45bcd9e2e06c69ea6fc5e49a9939.tar.gz
sonarqube-1b0a3a26064a45bcd9e2e06c69ea6fc5e49a9939.zip
SONAR-3255 Drilling down into violations from SQALE does not land properly
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/models')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb37
1 files changed, 22 insertions, 15 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 464f783eeab..d600cf6ef3c 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
@@ -98,20 +98,20 @@ class Snapshot < ActiveRecord::Base
def root_snapshot
@root_snapshot ||=
- (root_snapshot_id ? Snapshot.find(root_snapshot_id) : self)
+ (root_snapshot_id ? Snapshot.find(root_snapshot_id) : self)
end
def project_snapshot
@project_snapshot ||=
- begin
- if scope==Project::SCOPE_SET
- self
- elsif parent_snapshot_id
- parent_snapshot.project_snapshot
- else
- nil
- end
+ begin
+ if scope==Project::SCOPE_SET
+ self
+ elsif parent_snapshot_id
+ parent_snapshot.project_snapshot
+ else
+ nil
end
+ end
end
def root?
@@ -189,6 +189,13 @@ class Snapshot < ActiveRecord::Base
end
end
+ def rule_measure(metric, rule)
+ rulemeasures.each do |m|
+ return m if m.metric_id==metric.id && m.rule_id==rule.id
+ end
+ nil
+ end
+
def self.snapshot_by_date(resource_id, date)
if resource_id && date
Snapshot.find(:first, :conditions => ['created_at>=? and created_at<? and project_id=?', date.beginning_of_day, date.end_of_day, resource_id], :order => 'created_at desc')
@@ -245,13 +252,13 @@ class Snapshot < ActiveRecord::Base
def measures_hash
@measures_hash ||=
- begin
- hash = {}
- measures.each do |measure|
- hash[measure.metric_id]=measure
- end
- hash
+ begin
+ hash = {}
+ measures.each do |measure|
+ hash[measure.metric_id]=measure
end
+ hash
+ end
end
end