40 lines
836 B
Ruby
40 lines
836 B
Ruby
require 'erb'
|
|
require 'filesize'
|
|
require 'json'
|
|
|
|
load 'config.rb'
|
|
|
|
usernames = USERNAMES
|
|
shot_dir = SHOT_DIR
|
|
erb_file = ERB_FILE
|
|
html_file = HTML_FILE
|
|
|
|
bw = JSON.parse(`ruby bandwidth.rb`)
|
|
|
|
class User
|
|
attr_accessor :name, :count, :size, :avgsize, :bandwidth
|
|
def <=> other
|
|
other.count <=> count
|
|
end
|
|
end
|
|
|
|
users = []
|
|
usernames.each do |username|
|
|
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
|
|
user.bandwidth = bw[username]
|
|
|
|
users << user
|
|
end
|
|
|
|
File.open(html_file, 'w') do |f|
|
|
f << ERB.new(File.read erb_file).result
|
|
end
|