modify school contrast order logical

pre_develop
p31729568 6 years ago
parent ec8b047228
commit f0d41767e7

@ -62,7 +62,9 @@ class Management::SchoolDataContrastService
end
def query_report_sql(from_sql)
order_by = "(total = 0 AND other_total != 0) #{sort_direction}, (percentage != 0) #{sort_direction}, percentage #{sort_direction}"
"SELECT reports.*, (other_total - total) increase, (IF(other_total - total = 0, 0.0, round((other_total - total) / IF(total = 0, 1, total), 5))) percentage "\
"FROM (#{from_sql}) reports ORDER BY percentage #{sort_direction} LIMIT #{PAGE_SIZE} OFFSET #{offset}"
"FROM (#{from_sql}) reports ORDER BY #{order_by} LIMIT #{PAGE_SIZE} OFFSET #{offset}"
end
end

@ -45,7 +45,11 @@
<td class="edu-txt-right pr20 right-border relative color-red">
+<%= increase %>
</td>
<td class="edu-txt-left pl20 color-red">+<%= percentage.round(5) %>%</td>
<% if report['total'].zero? %>
<td class="edu-txt-left pl20">-</td>
<% else %>
<td class="edu-txt-left pl20 color-red">+<%= percentage.round(5) %>%</td>
<% end %>
<% elsif increase.zero? %>
<td class="edu-txt-right pr20 right-border" style="position: relative;">
<%= increase %>

Loading…
Cancel
Save