Permalink
Browse files

Fix percentage calculation formula

  • Loading branch information...
1 parent acd360c commit 508584c0667a46b6d7000910808ee00aebc2d62f @javiyu javiyu committed Feb 9, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/views/rails_admin/main/dashboard.html.haml
@@ -22,7 +22,7 @@
= t "admin.misc.ago"
%td
- count = @count[abstract_model.pretty_name]
- - percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count) * 100.0) / Math.log(@max)).to_i + 1) : -1
+ - percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count+1) * 100.0) / Math.log(@max+1)).to_i) : -1
@meghaarora42

meghaarora42 Apr 10, 2015

Contributor

Can someone kindly explain why is the percentage not simply (count*100/max)? Is this some other metric? I am asking because I have 2 models, one having a single record and the other having two. So, I was expecting the former progress bar to be at 50% and the latter at 100%, whereas I am getting 63% and 100% respectively.

@mshibuya

mshibuya Apr 10, 2015

Collaborator

Please refer to Logarithmic scale :)

@meghaarora42

meghaarora42 Apr 10, 2015

Contributor

Does it make sense to have a threshold on max and decide the scale accordingly? Isn't it better to have a linear scale for a lower max value?

.progress{:style => "margin-bottom:0px", :class => "progress-#{get_indicator(percent)} #{active && 'active progress-striped'}" }
.bar.animate-width-to{:'data-animate-length' => ([1.0, percent].max.to_i * 20), :'data-animate-width-to' => "#{[2.0, percent].max.to_i}%", :style => "width:2%"}
= @count[abstract_model.pretty_name]

0 comments on commit 508584c

Please sign in to comment.