about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-10-01 01:04:44 -0500
committermultiple creatures <dev@multiple-creature.party>2019-10-01 01:04:44 -0500
commit0944b9ca4b55f6b7fb4bbfee5e0c9f1744aa3148 (patch)
treeae58804621781c041729504a8656b7a4215c58d2
parentee1448ab1f4cc640e60515b6214c6fde1d98d4cf (diff)
add average & total to `histogram`
-rw-r--r--app/lib/bangtags.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 81aef2807..2c2101a85 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -721,12 +721,14 @@ class Bangtags
             raise Mastodon::ValidationError, 'Your advanced search query has invalid syntax.'
           end
           highest = data.values.max
+          avg = "<code>average: #{data.values.sum / data.count}</code>"
+          total = "<code>\u200c \u200c total: #{data.values.sum}</code>"
           data = data.map do |date, count|
             fill = count / highest.to_f * 96
             bar = "#{"\u2588" * (fill / 8).to_i}#{barchars[fill % 8]}"
             "<code>#{date}: #{bar} #{count}</code>"
           end
-          chunk = "\"<code>#{q.split('').join("\u200c")}</code>\" mentions by post count:<hr/>#{data.join("<br/>")}"
+          chunk = "<p>\"<code>#{q.split('').join("\u200c")}</code>\" mentions by post count:<hr/>#{data.join("<br/>")}<hr/>#{avg}<br/>#{total}</p>"
         when 'admin'
           chunk = nil
           next unless @user.admin?