Separate with comma views, likes, dislikes

This commit is contained in:
Omar Roth 2018-03-03 15:10:56 -06:00
parent 24cea8f3e7
commit 84c8fb9b99
2 changed files with 7 additions and 3 deletions

View file

@ -320,3 +320,7 @@ def template_comments(root)
return html return html
end end
def number_with_separator(number)
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
end

View file

@ -81,9 +81,9 @@ function dismiss(target) {
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1-5"> <div class="pure-u-1 pure-u-md-1-5">
<p><i class="fa fa-eye" aria-hidden="true"></i> <%= video.views %></p> <p><i class="fa fa-eye" aria-hidden="true"></i> <%= number_with_separator(video.views) %></p>
<p><i class="fa fa-thumbs-up" aria-hidden="true"></i> <%= video.likes %></p> <p><i class="fa fa-thumbs-up" aria-hidden="true"></i> <%= number_with_separator(video.likes) %></p>
<p><i class="fa fa-thumbs-down" aria-hidden="true"></i> <%= video.dislikes %></p> <p><i class="fa fa-thumbs-down" aria-hidden="true"></i> <%= number_with_separator(video.dislikes) %></p>
<p id="Wilson">Wilson Score : <%= video.wilson_score.round(4) %></p> <p id="Wilson">Wilson Score : <%= video.wilson_score.round(4) %></p>
<p id="Rating">Rating : <%= rating.round(4) %> / 5</p> <p id="Rating">Rating : <%= rating.round(4) %> / 5</p>
<p id="Engagement">Engagement : <%= engagement.round(2) %>%</p> <p id="Engagement">Engagement : <%= engagement.round(2) %>%</p>