2 technical_debt = measure('sqale_index')
4 root_characteristics = Internal.debt.characteristics().to_a
6 should_display_diff_measures = dashboard_configuration.selected_period? && technical_debt.variation(dashboard_configuration.period_index)!=nil
7 if technical_debt.nil? || root_characteristics.empty?
10 <h3><%= message('widget.technical_debt_pyramid.name') -%></h3>
11 <span style="color: #777777; font-size: 93%; font-style:italic"><%= message('widget.technical_debt_pyramid.no_info_available') -%></span>
17 table.technicalDebtPyramid td {
18 padding: 4px 10px 4px 0;
21 table.technicalDebtPyramid td.label {
25 padding: 5px 10px 5px 0;
28 table.technicalDebtPyramid th.val {
35 table.technicalDebtPyramid td.val {
42 table.technicalDebtPyramid td.bar {
46 table.technicalDebtPyramid .legendValue {
49 background-color: #4b9fd5;
50 display: inline-block;
51 zoom: 1; /* IE hack to trigger hasLayout */
52 *display: inline; /* IE hack to achieve inline-block behavior */
55 table.technicalDebtPyramid .legendTotal {
58 background-color: #cae3f2;
59 display: inline-block;
60 zoom: 1; /* IE hack to trigger hasLayout */
61 *display: inline; /* IE hack to achieve inline-block behavior */
64 table.technicalDebtPyramid td.bar>a>div>div {
69 <table class="technicalDebtPyramid">
72 <th colspan="2"><h3><%= message('widget.technical_debt_pyramid.name') -%></h3></th>
73 <th class="val"><%= message('widget.technical_debt_pyramid.technical_debt') -%> <div class="legendValue"></div></th>
74 <th class="val"><%= message('widget.technical_debt_pyramid.total') -%> <div class="legendTotal"></div></th>
79 measures_by_characteristic_id={}
80 ProjectMeasure.find(:all,
81 :conditions => ['characteristic_id IN (?) AND snapshot_id=? AND metric_id=?',
82 root_characteristics.map{|c| c.id}, @snapshot.id, technical_debt.metric().id]).each do |measure|
83 measures_by_characteristic_id[measure.characteristic_id]=measure
86 total = technical_debt.value
89 if should_display_diff_measures
90 diff_by_characteristic_id={}
92 root_characteristics.each do |c|
93 measure = measures_by_characteristic_id[c.id]
94 if measure && measure.variation(dashboard_configuration.period_index)
95 diff_by_characteristic_id[c.id] = measure.variation(dashboard_configuration.period_index)
96 total_diff += measure.variation(dashboard_configuration.period_index)
101 root_characteristics.sort_by {|characteristic| characteristic.order}.each do |characteristic|
102 measure=measures_by_characteristic_id[characteristic.id]
103 value=(measure && measure.value ? measure.value : 0)
104 total_size=(total>0 ? (100*cumulated/total).round(3): 0)
105 value_size=(cumulated>0 ? (100*value/cumulated).round(3): 100)
106 drilldown_url = url_for_drilldown('sqale_index', :characteristic => characteristic.key)
109 <td class="label"><%= h(characteristic.name) -%></td>
111 <a href="<%= drilldown_url -%>">
112 <div style="width: <%=total_size-%>%; height: 17px;background-color: #cae3f2;">
113 <div style="width: <%=value_size-%>%; height: 17px;background-color: #4b9fd5;"></div>
117 <td class="val value-debt-<%= h(characteristic.key) -%>">
118 <a href="<%= drilldown_url -%>" class="underlined-link link-debt-<%= h(characteristic.key) -%>"><%= Internal.i18n.formatLongDuration(value.to_i, 'SHORT') -%></a>
119 <% if should_display_diff_measures %>
120 <% if diff_by_characteristic_id[characteristic.id] %>
121 <%= format_variation(measure) -%>
123 <span class="var"><b>(+0)</b></span>
127 <td class="val value-total-<%= h(characteristic.key) -%>">
128 <%= Internal.i18n.formatLongDuration(cumulated.to_i, 'SHORT') -%>
130 if should_display_diff_measures
132 css_style += 'b' if total_diff < 0
133 css_style += 'w' if total_diff > 0
134 diff_to_display = (total_diff < 0 ? '' : '+') + Internal.i18n.formatLongDuration(total_diff.to_i, 'SHORT')
136 <span class="<%= css_style -%>"><b>(<%= diff_to_display -%>)</b></span>
138 total_diff -= diff_by_characteristic_id[characteristic.id] if diff_by_characteristic_id[characteristic.id]