From 9253f93c64a51ca891d9a29b55fd004600ac5025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Mon, 8 May 2017 22:54:05 +0200 Subject: [PATCH] add new stats page --- stats.erb | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 stats.erb diff --git a/stats.erb b/stats.erb new file mode 100644 index 0000000..892ef08 --- /dev/null +++ b/stats.erb @@ -0,0 +1,59 @@ + + + + Statistics for dcav.pw + + + + + +

Screenshot statistics for dcav.pw

+

Leaderboards

+ + + + + + + + <% + require 'filesize' + class User + include Comparable + attr_accessor :name,:count,:size + def <=> (other) + other.count <=> count + end + end + usernames = ["christoffermadsen","jmaa","jacob","alexander"] + users = [] + shot_dir = "/var/shots/" + usernames.each do |username| + user = User.new + user.name = username + size = `du -B1 #{shot_dir}#{username}/ | awk {'print $1'} | head -n 1` + count = `ls -1 #{shot_dir}#{username}/ | wc -l | head -n 1` + [size,count].each do |x| + x.delete! "\n" + end + user.size = size.to_i + user.count = count.to_i + users << user + end + count = 0 + users.sort.each do |user| + count += 1 + %> + <%= "" %> + <% end %> +
NameCountSize
#{count}#{user.name}#{user.count}#{Filesize.from(user.size.to_s + "B").pretty}
+

Charts

+ +
+ +
+ +
+ Page generated at <%= Time.now %> + +