diff --git a/dcav-index.erb b/dcav-index.erb
index 126608f..c35126d 100644
--- a/dcav-index.erb
+++ b/dcav-index.erb
@@ -15,6 +15,7 @@
Name |
Count |
Size |
+ Average size |
<% order = 0
users.sort.each do |user|
@@ -26,6 +27,7 @@
#{user.name} |
#{user.count} |
#{Filesize.from(user.size.to_s + "B").pretty} |
+ #{Filesize.from(user.avgsize.to_s + "B").pretty} |
}
%>
<% end %>
diff --git a/gen_index.rb b/gen_index.rb
index a29e014..557052c 100644
--- a/gen_index.rb
+++ b/gen_index.rb
@@ -8,7 +8,7 @@ erb_file = "dcav-index.erb"
html_file = "/var/shots/html/index.html"
class User
- attr_accessor :name, :count, :size
+ attr_accessor :name, :count, :size, :avgsize
def <=> other
other.count <=> count
end
@@ -16,14 +16,15 @@ 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 = 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
users << user
end