@Property(
key = "sonar.timemachine.variation1",
name = "Variation 1",
- description = "To be defined. For the moment the number of days",
+ description = "Period used to compare measures and track new violations. Values are : <ul><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
project = false,
global = true
),
# Display the trend icon :
#
# === Optional parameters
- # * big: true|false. Default is false.
# * empty: true|false. Show an empty transparent image when no trend or no measure. Default is false.
#
# === Examples
m = @snapshot.measure(metric_or_measure)
end
- big=options[:big]||false
if m.nil? || m.tendency.nil? || m.tendency==0
- return options[:empty] ? image_tag("transparent.gif", :width => big ? "18" : "16", :alt => "") : nil
+ return options[:empty] ? image_tag("transparent.gif", :width => "16", :alt => "") : nil
end
filename = m.tendency.to_s
when 1
filename+= '-green'
end
- suffix = (big ? '' : '-small')
- image_tag("tendency/#{filename}#{suffix}.png")
+ image_tag("tendency/#{filename}-small.png")
end
#
# Numeric value of variation
#
# === Optional parameters
- # * index: integer between 1 and 3. By default the index is defined by the dashboard variation select-box
+ # * index: integer between 1 and 5. By default the index is defined by the dashboard variation select-box
#
# === Examples
# variation_value('ncloc')
#
# === Optional parameters
# * color: true|false. Default is true.
- # * index: integer between 1 and 3. By default the index is defined by the dashboard variation select-box
+ # * index: integer between 1 and 5. By default the index is defined by the dashboard variation select-box
#
# === Examples
# format_variation('ncloc')
if mode
if mode=='days'
- label = "Last %s days" % mode_param
+ label = "Compare to %s previous days" % mode_param
elsif mode=='version'
- label = "Version %s" % mode_param
+ label = "Compare to version %s" % mode_param
elsif mode=='previous_analysis'
- label = "Previous analysis (%s)" % localize(Date.parse(mode_param))
+ label = "Compare to previous analysis (%s)" % localize(Date.parse(mode_param))
elsif mode=='date'
- label = localize(Date.parse(mode_param))
+ label = "Compare to #{localize(Date.parse(mode_param))}"
end
if label
selected=(params[:var]==index.to_s ? 'selected' : '')
else
nil
end
-
end
end
\ No newline at end of file
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
module DrilldownHelper
- include DashboardHelper
+
+ def variation_select_option(snapshot, index)
+ return nil if snapshot.nil? || snapshot.project_snapshot.nil?
+ mode=snapshot.project_snapshot.send "variation_mode_#{index}"
+ mode_param=snapshot.project_snapshot.send "variation_param_#{index}"
+
+ if mode
+ if mode=='days'
+ label = "New violations from %s previous days" % mode_param
+ elsif mode=='version'
+ label = "New violations since version %s" % mode_param
+ elsif mode=='previous_analysis'
+ label = "New violations since previous analysis (%s)" % localize(Date.parse(mode_param))
+ elsif mode=='date'
+ label = "New violations since #{localize(Date.parse(mode_param))}"
+ end
+ if label
+ selected=(params[:var]==index.to_s ? 'selected' : '')
+ "<option value='#{index}' #{selected}>#{label}</option>"
+ end
+ else
+ nil
+ end
+
+ end
def measure_or_variation_value(measure)
if measure
project
end
+ def variation_modes?
+ (variation_mode_1 || variation_mode_2 || variation_mode_3 || variation_mode_4 || variation_mode_5) != nil
+ end
+
def resource_id_for_authorization
root_project_id || project_id
end
%>
<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
- - Compare to
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
- <select id="select-comparison" name="var" onchange="submit()" class="small">
- <option value=""></option>
- <%= variation_select_option(@snapshot, 1) -%>
- <%= variation_select_option(@snapshot, 2) -%>
- <%= variation_select_option(@snapshot, 3) -%>
- <%= variation_select_option(@snapshot, 4) -%>
- <%= variation_select_option(@snapshot, 5) -%>
- </select>
- </form>
+ <% if @snapshot.project_snapshot.variation_modes? %>
+ -
+ <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">Display trends</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+ <% end %>
</h4>
</div>
<% end %>
%>
<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
+<% if @snapshot.project_snapshot.variation_modes? %>
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
- <select id="select-comparison" name="var" onchange="submit()" class="small">
- <option value="">All violations</option>
- <%= variation_select_option(@snapshot, 1) -%>
- <%= variation_select_option(@snapshot, 2) -%>
- <%= variation_select_option(@snapshot, 3) -%>
- <%= variation_select_option(@snapshot, 4) -%>
- <%= variation_select_option(@snapshot, 5) -%>
- </select>
- </form>
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">All violations</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+<% end %>
</h4>
</div>