aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-01 16:31:22 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-04 10:25:07 +0200
commit5112fc0bc1bc9c1725235ffcf3031060a44e3567 (patch)
treef93ddb6ab59fdc2bb528e3a55f2bada8bb2fdfeb /server/sonar-web/src
parent479c7533db672c2e4b96e8fdcc41142570c39069 (diff)
downloadsonarqube-5112fc0bc1bc9c1725235ffcf3031060a44e3567.tar.gz
sonarqube-5112fc0bc1bc9c1725235ffcf3031060a44e3567.zip
SONAR-7780 Apply feedback
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb98
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb6
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/chart_measure.rb28
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/loaded_template.rb22
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb36
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb29
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/timemachine_row.rb23
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb10
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb4
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/project/history.html.erb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developer_projects.rb (renamed from server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developers.rb)4
15 files changed, 87 insertions, 183 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
index 4269dee6bb5..613f5cc2af5 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
@@ -137,7 +137,7 @@ class Api::EventsController < Api::ApiController
end
raise "A version already exists on this resource." if params[:category]==EventCategory::KEY_VERSION && root_snapshot.event(EventCategory::KEY_VERSION)
- raise "An event '#{params[:name]}' (category '#{params[:category]}') already exists on this resource." if Event.already_exists(@resource.last_snapshot.id, params[:name], params[:category])
+ raise "An event '#{params[:name]}' (category '#{params[:category]}') already exists on this resource." if Event.already_exists(@resource.last_analysis.id, params[:name], params[:category])
# Create events for the root project and every submodule
event_to_return = nil
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
index 3462125a2bc..8c4487bd1f9 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
@@ -104,7 +104,7 @@ class Api::ResourcesController < Api::ApiController
resource_id=params[:resource]
if resource_id
@resource=Project.by_key(resource_id)
- @analysis=(@resource && @resource.last_snapshot)
+ @analysis=(@resource && @resource.last_analysis)
raise ApiException.new(404, "Resource [#{resource_id}] not found") if @analysis.nil?
raise ApiException.new(401, "Unauthorized") unless has_role?(:user, @resource)
else
@@ -195,7 +195,7 @@ class Api::ResourcesController < Api::ApiController
# ---------- LOAD COMPONENTS
# H2 does not support empty lists, so short-breaking if no measures
- if load_measures && measures_by_component_uuid.empty?
+ if measures_limit && measures_by_component_uuid.empty?
components = []
else
components = Project.all(
@@ -284,7 +284,7 @@ class Api::ResourcesController < Api::ApiController
xml.resources do
components.each do |component|
measures = measures_by_component_uuid[component.uuid]
- resource_to_xml(xml, component, measures, params)
+ component_to_xml(xml, component, measures, params)
end
end
end
@@ -310,26 +310,26 @@ class Api::ResourcesController < Api::ApiController
json['version']= component.last_analysis.version if component.last_analysis && component.last_analysis.version
json['branch']=component.branch if component.branch
json['description']=component.description if component.description
- if include_trends && component.last_snapshot
- json[:p1]=component.last_snapshot.period1_mode if component.last_snapshot.period1_mode
- json[:p1p]=component.last_snapshot.period1_param if component.last_snapshot.period1_param
- json[:p1d]=Api::Utils.format_datetime(component.last_snapshot.period1_date) if component.last_snapshot.period1_date
-
- json[:p2]=component.last_snapshot.period2_mode if component.last_snapshot.period2_mode
- json[:p2p]=component.last_snapshot.period2_param if component.last_snapshot.period2_param
- json[:p2d]=Api::Utils.format_datetime(component.last_snapshot.period2_date) if component.last_snapshot.period2_date
-
- json[:p3]=component.last_snapshot.period3_mode if component.last_snapshot.period3_mode
- json[:p3p]=component.last_snapshot.period3_param if component.last_snapshot.period3_param
- json[:p3d]=Api::Utils.format_datetime(component.last_snapshot.period3_date) if component.last_snapshot.period3_date
-
- json[:p4]=component.last_snapshot.period4_mode if component.last_snapshot.period4_mode
- json[:p4p]=component.last_snapshot.period4_param if component.last_snapshot.period4_param
- json[:p4d]=Api::Utils.format_datetime(component.last_snapshot.period4_date) if component.last_snapshot.period4_date
-
- json[:p5]=component.last_snapshot.period5_mode if component.last_snapshot.period5_mode
- json[:p5p]=component.last_snapshot.period5_param if component.last_snapshot.period5_param
- json[:p5d]=Api::Utils.format_datetime(component.last_snapshot.period5_date) if component.last_snapshot.period5_date
+ if include_trends && component.last_analysis
+ json[:p1]=component.last_snapshot.period1_mode if component.last_analysis.period1_mode
+ json[:p1p]=component.last_analysis.period1_param if component.last_analysis.period1_param
+ json[:p1d]=Api::Utils.format_datetime(component.last_analysis.period1_date) if component.last_analysis.period1_date
+
+ json[:p2]=component.last_analysis.period2_mode if component.last_analysis.period2_mode
+ json[:p2p]=component.last_analysis.period2_param if component.last_analysis.period2_param
+ json[:p2d]=Api::Utils.format_datetime(component.last_analysis.period2_date) if component.last_analysis.period2_date
+
+ json[:p3]=component.last_analysis.period3_mode if component.last_analysis.period3_mode
+ json[:p3p]=component.last_analysis.period3_param if component.last_analysis.period3_param
+ json[:p3d]=Api::Utils.format_datetime(component.last_analysis.period3_date) if component.last_analysis.period3_date
+
+ json[:p4]=component.last_analysis.period4_mode if component.last_analysis.period4_mode
+ json[:p4p]=component.last_analysis.period4_param if component.last_analysis.period4_param
+ json[:p4d]=Api::Utils.format_datetime(component.last_analysis.period4_date) if component.last_analysis.period4_date
+
+ json[:p5]=component.last_analysis.period5_mode if component.last_analysis.period5_mode
+ json[:p5p]=component.last_analysis.period5_param if component.last_analysis.period5_param
+ json[:p5d]=Api::Utils.format_datetime(component.last_analysis.period5_date) if component.last_analysis.period5_date
end
if measures
json_measures=[]
@@ -365,7 +365,7 @@ class Api::ResourcesController < Api::ApiController
json
end
- def resource_to_xml(xml, component, measures, options={})
+ def component_to_xml(xml, component, measures, options={})
verbose=(options[:verbose]=='true')
include_alerts=(options[:includealerts]=='true')
include_trends=(options[:includetrends]=='true')
@@ -380,31 +380,31 @@ class Api::ResourcesController < Api::ApiController
xml.scope(component.scope)
xml.qualifier(component.qualifier)
xml.lang(component.language) if component.language
- xml.version(snapshot.version) if snapshot.version
- xml.date(Api::Utils.format_datetime(snapshot.created_at))
- xml.creationDate(Api::Utils.format_datetime(resource.created_at))
- xml.description(resource.description) if include_descriptions && resource.description
-
- if include_trends && component.last_snapshot
- xml.period1(component.last_snapshot.period1_mode) if component.last_snapshot.period1_mode
- xml.period1_param(component.last_snapshot.period1_param) if component.last_snapshot.period1_param
- xml.period1_date(Api::Utils.format_datetime(component.last_snapshot.period1_date)) if component.last_snapshot.period1_date
-
- xml.period2(component.last_snapshot.period2_mode) if component.last_snapshot.period2_mode
- xml.period2_param(component.last_snapshot.period2_param) if component.last_snapshot.period2_param
- xml.period2_date(Api::Utils.format_datetime(component.last_snapshot.period2_date)) if component.last_snapshot.period2_date
-
- xml.period3(component.last_snapshot.period3_mode) if component.last_snapshot.period3_mode
- xml.period3_param(component.last_snapshot.period3_param) if component.last_snapshot.period3_param
- xml.period3_date(Api::Utils.format_datetime(component.last_snapshot.period3_date)) if component.last_snapshot.period3_date
-
- xml.period4(component.last_snapshot.period4_mode) if component.last_snapshot.period4_mode
- xml.period4_param(component.last_snapshot.period4_param) if component.last_snapshot.period4_param
- xml.period4_date(Api::Utils.format_datetime(component.last_snapshot.period4_date)) if component.last_snapshot.period4_date
-
- xml.period5(component.last_snapshot.period5_mode) if component.last_snapshot.period5_mode
- xml.period5_param(component.last_snapshot.period5_param) if component.last_snapshot.period5_param
- xml.period5_date(Api::Utils.format_datetime(component.last_snapshot.period5_date)) if component.last_snapshot.period5_date
+ xml.version(component.last_analysis.version) if component.last_analysis && component.last_analysis.version
+ xml.date(Api::Utils.format_datetime(component.last_analysis.created_at)) if component.last_analysis
+ xml.creationDate(Api::Utils.format_datetime(component.created_at))
+ xml.description(component.description) if include_descriptions && component.description
+
+ if include_trends && component.last_analysis
+ xml.period1(component.last_analysis.period1_mode) if component.last_analysis.period1_mode
+ xml.period1_param(component.last_analysis.period1_param) if component.last_analysis.period1_param
+ xml.period1_date(Api::Utils.format_datetime(component.last_analysis.period1_date)) if component.last_analysis.period1_date
+
+ xml.period2(component.last_analysis.period2_mode) if component.last_analysis.period2_mode
+ xml.period2_param(component.last_analysis.period2_param) if component.last_analysis.period2_param
+ xml.period2_date(Api::Utils.format_datetime(component.last_analysis.period2_date)) if component.last_analysis.period2_date
+
+ xml.period3(component.last_analysis.period3_mode) if component.last_analysis.period3_mode
+ xml.period3_param(component.last_analysis.period3_param) if component.last_analysis.period3_param
+ xml.period3_date(Api::Utils.format_datetime(component.last_analysis.period3_date)) if component.last_analysis.period3_date
+
+ xml.period4(component.last_analysis.period4_mode) if component.last_analysis.period4_mode
+ xml.period4_param(component.last_analysis.period4_param) if component.last_analysis.period4_param
+ xml.period4_date(Api::Utils.format_datetime(component.last_analysis.period4_date)) if component.last_analysis.period4_date
+
+ xml.period5(component.last_analysis.period5_mode) if component.last_analysis.period5_mode
+ xml.period5_param(component.last_analysis.period5_param) if component.last_analysis.period5_param
+ xml.period5_date(Api::Utils.format_datetime(component.last_analysis.period5_date)) if component.last_analysis.period5_date
end
if measures
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
index 308c9d9fd09..c63e11970c1 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
@@ -30,9 +30,9 @@ class ComparisonController < ApplicationController
project = Project.by_key(resource_key)
return render_not_found('Project not found') unless project
- snapshots = project.events.select { |event| !event.snapshot.nil? && event.category==EventCategory::KEY_VERSION }[0..5].reverse.map {|e| e.snapshot}
+ snapshots = project.events.select { |event| event.snapshot && event.category==EventCategory::KEY_VERSION }[0..5].reverse.map {|e| e.snapshot}
# if last snapshot is not in the list, add it at the end (=> might be the case for views or developers which do not have events)
- last_snapshot = project.last_snapshot
+ last_snapshot = project.last_analysis
unless snapshots.last == last_snapshot
snapshots.shift
snapshots.push(last_snapshot)
@@ -79,7 +79,7 @@ class ComparisonController < ApplicationController
@versions = project.events.select { |event| event.category==EventCategory::KEY_VERSION && !suuids.include?(event.analysis_uuid.to_s) }
# check if the latest snapshot if suggested or not (and if not, suggest it as "LATEST" => this is used for views or developers which do not have events)
- latest_snapshot_uuid = project.last_snapshot.uuid
+ latest_snapshot_uuid = project.last_analysis.uuid
current_and_suggested_suuids = suuids + @versions.map {|e| e.analysis_uuid.to_s}
unless current_and_suggested_suuids.include?(latest_snapshot_uuid.to_s)
@versions.unshift Event.new(:name => Api::Utils.message('comparison.version.latest'), :analysis_uuid => latest_snapshot_uuid)
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
index ea2037248d5..15523f43e32 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
@@ -218,7 +218,7 @@ class ProjectController < ApplicationController
redirect_to :action => 'index', :id => params[:id]
end
- @snapshot = @project.last_snapshot
+ @snapshot = @project.last_analysis
@analyses = Snapshot.all(:conditions => ["status='P' AND component_uuid=?", @project.uuid],
:include => 'events', :order => 'snapshots.created_at DESC')
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/chart_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/chart_measure.rb
deleted file mode 100644
index 3f53336a0a1..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/chart_measure.rb
+++ /dev/null
@@ -1,28 +0,0 @@
- #
- # SonarQube, open source software quality management tool.
- # Copyright (C) 2008-2014 SonarSource
- # mailto:contact AT sonarsource DOT com
- #
- # SonarQube is free software; you can redistribute it and/or
- # modify it under the terms of the GNU Lesser General Public
- # License as published by the Free Software Foundation; either
- # version 3 of the License, or (at your option) any later version.
- #
- # SonarQube is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # Lesser General Public License for more details.
- #
- # You should have received a copy of the GNU Lesser General Public License
- # License along with {library}; if not, write to the Free Software
- # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- #
-class ChartMeasure
- attr_accessor :time, :value
-
- def initialize(time, value)
- @time = time
- @value = value
- end
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/loaded_template.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/loaded_template.rb
deleted file mode 100644
index d04448352d9..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/loaded_template.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 3 of the License, or (at your option) any later version.
-#
-# SonarQube is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-class LoadedTemplate < ActiveRecord::Base
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
index a45fdf9565d..974a1173b87 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
@@ -286,7 +286,7 @@ class MeasureFilter < ActiveRecord::Base
rows_by_component_uuid[component.uuid].set_analysis(analysis) if analysis
end
- # @rows must be in the same order than the component uuids
+ # @rows must be in the same order as the component uuids
component_uuids.each do |uuid|
@rows << rows_by_component_uuid[uuid]
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
index f127996894c..863b6bf1a67 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
@@ -32,7 +32,7 @@ class Project < ActiveRecord::Base
has_many :authors, :foreign_key => 'person_id', :dependent => :delete_all
has_one :index, :class_name => 'ResourceIndex', :foreign_key => 'component_uuid', :primary_key => 'uuid', :conditions => 'position=0', :select => 'kee'
has_many :resource_index, :foreign_key => 'resource_id'
- has_one :last_analysis, :class_name => 'Snapshot', :foreign_key => 'component_uuid', :primary_key => 'uuid', :conditions => ['snapshots.islast=?', true]
+ has_one :last_analysis, :class_name => 'Snapshot', :foreign_key => 'component_uuid', :primary_key => 'project_uuid', :conditions => ['snapshots.islast=?', true]
def self.by_key(k)
begin
@@ -68,6 +68,10 @@ class Project < ActiveRecord::Base
root||self
end
+ def root?
+ project_uuid == uuid
+ end
+
def root_project
@root_project ||=
begin
@@ -141,17 +145,6 @@ class Project < ActiveRecord::Base
links.reject { |l| l.custom? }
end
- def chart_measures(metric_id)
- sql = Project.send(:sanitize_sql, ['select s.created_at as created_at, m.value as value ' +
- ' from project_measures m, snapshots s ' +
- ' where s.id=m.snapshot_id and ' +
- " s.status='%s' and " +
- ' s.component_uuid=%s and m.metric_id=%s ', 'P', self.uuid, metric_id]) +
- ' and m.person_id IS NULL' +
- ' order by s.created_at'
- create_chart_measures(Project.connection.select_all(sql), 'created_at', 'value')
- end
-
def <=>(other)
kee <=> other.kee
end
@@ -184,25 +177,6 @@ class Project < ActiveRecord::Base
private
- def create_chart_measures(results, date_column_name, value_column_name)
- chart_measures = []
- if results and results.first != nil
- # :sanitize_sql is protected so its behaviour cannot be predicted exactly,
- # the jdbc active record impl adapter returns a db typed objects array
- # when regular active record impl return string typed objects
- if results.first[date_column_name].class == Time
- results.each do |hash|
- chart_measures << ChartMeasure.new(hash[date_column_name], hash[value_column_name])
- end
- else
- results.each do |hash|
- chart_measures << ChartMeasure.new(Time.parse(hash[date_column_name]), hash[value_column_name].to_d)
- end
- end
- end
- chart_measures
- end
-
def parent_module(current_module)
current_module.root.uuid = current_module.uuid ? current_module : parent_module(current_module.root)
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb
index 3d75143d817..f9b3f553a96 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb
@@ -65,29 +65,6 @@ class Snapshot < ActiveRecord::Base
Time.at(date_in_long/1000) if date_in_long
end
- def self.for_timemachine_matrix(resource)
- # http://jira.sonarsource.com/browse/SONAR-1850
- # Conditions on scope and qualifier are required to exclude library snapshots.
- # Use-case :
- # 1. project A 2.0 is analyzed -> new snapshot A with qualifier TRK
- # 2. project B, which depends on A 1.0, is analyzed -> new snapshot A 1.0 with qualifier LIB.
- # 3. project A has 2 snapshots : the first one with qualifier=TRK has measures, the second one with qualifier LIB has no measures. Its version must not be used in time machine
- # That's why the 2 following SQL requests check the qualifiers (and optionally scopes, just to be sure)
- snapshots=Snapshot.find(:all, :conditions => ["snapshots.component_uuid=? AND events.analysis_uuid=snapshots.uuid AND snapshots.status=? AND snapshots.scope=? AND snapshots.qualifier=?", resource.uuid, STATUS_PROCESSED, resource.scope, resource.qualifier],
- :include => 'events',
- :order => 'snapshots.created_at ASC')
-
- snapshots<<resource.last_snapshot if snapshots.empty?
-
- snapshots=snapshots[-5, 5] if snapshots.size>=5
-
- snapshots.insert(0, Snapshot.find(:first,
- :conditions => ["component_uuid=? AND status=? AND scope=? AND qualifier=?", resource.uuid, STATUS_PROCESSED, resource.scope, resource.qualifier],
- :include => 'project', :order => 'snapshots.created_at ASC', :limit => 1))
-
- snapshots.compact.uniq
- end
-
def self.for_timemachine_widget(resource, number_of_columns, options={})
if number_of_columns == 1
# Display only the latest snapshot
@@ -95,13 +72,13 @@ class Snapshot < ActiveRecord::Base
end
# Get 1rst & latests snapshots of the period
- snapshot_conditions = ["snapshots.component_uuid=? AND snapshots.status=? AND snapshots.scope=? AND snapshots.qualifier=?", resource.uuid, STATUS_PROCESSED, resource.scope, resource.qualifier]
+ snapshot_conditions = ["snapshots.component_uuid=? AND snapshots.status=?", resource.project_uuid, STATUS_PROCESSED]
if options[:from]
snapshot_conditions[0] += " AND snapshots.created_at>=?"
snapshot_conditions << options[:from].to_i * 1000
end
- first_snapshot=Snapshot.find(:first, :conditions => snapshot_conditions, :order => 'snapshots.created_at ASC')
- last_snapshot=resource.last_snapshot
+ first_snapshot = Snapshot.find(:first, :conditions => snapshot_conditions, :order => 'snapshots.created_at ASC')
+ last_snapshot = resource.last_analysis
if first_snapshot==last_snapshot
return [last_snapshot]
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/timemachine_row.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/timemachine_row.rb
index 2bc9e959f35..c4c8c98041a 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/timemachine_row.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/timemachine_row.rb
@@ -22,15 +22,15 @@ class Sonar::TimemachineRow
def initialize(metric)
@metric=metric
- @measure_by_sid={}
+ @measures_by_analysis_uuid = {}
end
def add_measure(measure)
- @measure_by_sid[measure.snapshot_id]=measure
+ @measures_by_analysis_uuid[measure.analysis_uuid] = measure
end
- def measure(snapshot)
- @measure_by_sid[snapshot.id]
+ def measure(analysis)
+ @measures_by_analysis_uuid[analysis.uuid]
end
def domain
@@ -41,14 +41,17 @@ class Sonar::TimemachineRow
(self.domain <=> other.domain).nonzero? || (self.metric.short_name <=> other.metric.short_name)
end
- def sparkline
- if metric.numeric? && @measure_by_sid.size > 1
+ def sparkline(analyses)
+ if metric.numeric? && @measures_by_analysis_uuid.size > 1
x = []
y = []
- @measure_by_sid.values.each do |measure|
- # date.to_f does not works under oracle
- x << measure.snapshot.created_at.to_s(:number)
- y << (measure.value.nil? ? 0 : measure.value)
+ analyses.each do |analysis|
+ m = measure(analysis)
+ if m
+ # date.to_f does not works under oracle
+ x << analysis.created_at.to_s(:number)
+ y << (m.value.nil? ? 0 : m.value)
+ end
end
[x, y]
else
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb
index f681c28b3d7..397fe455819 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb
@@ -19,12 +19,12 @@
#
class TrendsChart
- def self.time_machine_measures(resource, metric_ids, options={})
+ def self.time_machine_measures(component, metric_ids, options={})
unless metric_ids.empty?
- sql= "select s.created_at as created_at, m.value as value, m.metric_id as metric_id, s.id as sid " +
- " from project_measures m LEFT OUTER JOIN snapshots s ON s.id=m.snapshot_id " +
+ sql= "select s.created_at as created_at, m.value as value, m.metric_id as metric_id, s.uuid as analysis_uuid " +
+ " from project_measures m LEFT OUTER JOIN snapshots s ON s.uuid = m.analysis_uuid " +
" where s.status=? " +
- " and s.component_uuid=? " +
+ " and m.component_uuid=? " +
" and m.metric_id in (?) " +
" and m.person_id is null"
if (options[:from])
@@ -34,7 +34,7 @@ class TrendsChart
sql += ' and s.created_at<=?'
end
sql += ' order by s.created_at ASC'
- conditions=[sql, Snapshot::STATUS_PROCESSED, resource.uuid, metric_ids]
+ conditions=[sql, Snapshot::STATUS_PROCESSED, component.uuid, metric_ids]
if (options[:from])
conditions<<options[:from].to_i*1000
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb
index e1cb44b4475..2a7d0e94282 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb
@@ -1,6 +1,6 @@
<div id="body" class="page">
- <% if @snapshot %>
- <div class="print"><h2><%= h @snapshot.project.name(true) %></h2></div>
+ <% if @resource %>
+ <div class="print"><h2><%= h @resource.name(true) %></h2></div>
<% end %>
<div class="hidden" id="messages-panel">
<div class="alert alert-danger hidden" id="error">
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
index 73bdb62f6be..da66ac28b95 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb
@@ -1,6 +1,6 @@
<div class="page">
<%
- if !@snapshot || @snapshot.root?
+ if !@snapshot || @project.root?
resource_qualifier = message('qualifier.' + @project.qualifier)
delete_resource_message = message('project_deletion.page', :params => resource_qualifier)
%>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/history.html.erb
index 080cbe7523d..2e9414bb4b8 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/history.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/history.html.erb
@@ -15,7 +15,7 @@
<code><%= h @project.key -%></code>
</div>
- <% elsif @snapshot.root? %>
+ <% elsif @project.root? %>
<table id="project-history" class="data" style="width:1%">
<thead>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developers.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developer_projects.rb
index 568fa301801..38cf8c1a960 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developers.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_fix_project_uuid_of_developer_projects.rb
@@ -21,9 +21,9 @@
#
# SonarQube 6.0
#
-class FixProjectUuidOfDevelopers < ActiveRecord::Migration
+class FixProjectUuidOfDeveloperProjects < ActiveRecord::Migration
def self.up
- execute_java_migration('org.sonar.db.version.v60.FixProjectUuidOfDevelopers')
+ execute_java_migration('org.sonar.db.version.v60.FixProjectUuidOfDeveloperProjects')
end
end