Browse Source

Use compare method from engine to sort grades

Norore 1 month ago
parent
commit
6ece39abdb
  1. 23
      app/views/statistics/index.html.erb

23
app/views/statistics/index.html.erb

@ -36,7 +36,6 @@
aria-labelledby="nav-<%= service %>-pill">
<h2>Grades for service <%= service.to_s.upcase %></h2>
<%
grades = Stat["grades_for_#{service}"]
total = grades.data.collect { _2 }.sum
@ -54,10 +53,12 @@
</tr>
</thead>
<tbody>
<% grades.data.sort_by(&:first).each do |grade, number|
unless %w(T V).include?(grade)
percent = (number.to_f / total.to_f) * 100.0
color = colors[grade] %>
<% sorted_grades = grades.data.keys.sort &CryptCheck::Grade.method(:compare)
sorted_grades.each do |grade|
unless %w(T V).include?(grade)
number = grades.data[grade].to_i
percent = (number.to_f / total.to_f) * 100.0
color = CryptCheck::Grade::GRADE_STATUS.fetch grade.to_sym %>
<tr>
<td><%= grade %></td>
<td><%= percent.round %>%</td>
@ -94,9 +95,11 @@
</tr>
</thead>
<tbody>
<% ciphers.data.sort_by(&:first).each do |grade, number|
percent = (number.to_f / total.to_f) * 100.0
color = colors[grade]
<% sorted_grades = ciphers.data.keys.sort &CryptCheck::Grade.method(:compare)
sorted_grades.each do |grade|
number = ciphers.data[grade]
percent = (number.to_f / total.to_f) * 100.0
color = colors[grade]
%>
<tr>
<td><%= grade.capitalize %></td>
@ -133,7 +136,9 @@
</thead>
<tbody>
<%
tls.data.sort_by(&:first).each do |grade, number|
sorted_grades = tls.data.keys.sort &CryptCheck::Grade.method(:compare)
sorted_grades.each do |grade|
number = tls.data[grade]
percent = (number.to_f / total.to_f) * 100.0
color = colors[grade]
%>

Loading…
Cancel
Save