2017-05-08 22:07:59 +00:00
|
|
|
require 'erb'
|
|
|
|
require 'filesize'
|
2017-05-22 22:09:10 +00:00
|
|
|
require 'json'
|
2017-05-08 22:07:59 +00:00
|
|
|
|
2017-05-09 11:40:42 +00:00
|
|
|
load 'config.rb'
|
|
|
|
|
|
|
|
usernames = USERNAMES
|
|
|
|
shot_dir = SHOT_DIR
|
|
|
|
erb_file = ERB_FILE
|
|
|
|
html_file = HTML_FILE
|
2017-05-08 22:07:59 +00:00
|
|
|
|
2017-05-22 22:09:10 +00:00
|
|
|
bw = JSON.parse(`ruby bandwidth.rb`)
|
|
|
|
|
2017-05-08 22:07:59 +00:00
|
|
|
class User
|
2017-05-22 22:09:10 +00:00
|
|
|
attr_accessor :name, :count, :size, :avgsize, :bandwidth
|
2017-05-09 10:02:15 +00:00
|
|
|
def <=> other
|
2017-05-08 22:07:59 +00:00
|
|
|
other.count <=> count
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-09 10:02:15 +00:00
|
|
|
users = []
|
2017-05-08 22:07:59 +00:00
|
|
|
usernames.each do |username|
|
2017-05-09 10:41:33 +00:00
|
|
|
user = User.new
|
|
|
|
user.name = username
|
|
|
|
user.size = `du -B1 #{shot_dir}#{username}/ | awk {'print $1'} | head -n 1`
|
|
|
|
.delete("\n")
|
|
|
|
.to_i
|
|
|
|
user.count = `ls -1 #{shot_dir}#{username}/ | wc -l | head -n 1`
|
|
|
|
.delete("\n")
|
|
|
|
.to_i
|
|
|
|
user.avgsize = user.size / user.count
|
2017-05-22 22:09:10 +00:00
|
|
|
user.bandwidth = bw[username]
|
|
|
|
|
|
|
|
users << user
|
2017-05-08 22:07:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
File.open(html_file, 'w') do |f|
|
2017-05-09 10:02:15 +00:00
|
|
|
f << ERB.new(File.read erb_file).result
|
2017-05-08 22:07:59 +00:00
|
|
|
end
|