From 8a0051a6fdd00f83e566cc87b88d2ac23ad5487d Mon Sep 17 00:00:00 2001 From: Misha Zatsman Date: Wed, 23 Apr 2014 01:14:31 +0000 Subject: [PATCH] Working users/storage page! --- .../app/controllers/users_controller.rb | 17 +++++++++++++++++ apps/workbench/app/views/users/storage.html.erb | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb index cf61c4bb22..72d44f51c2 100644 --- a/apps/workbench/app/controllers/users_controller.rb +++ b/apps/workbench/app/controllers/users_controller.rb @@ -66,6 +66,23 @@ class UsersController < ApplicationController def storage @breadcrumb_page_name = nil @users = User.limit(params[:limit] || 1000).all + @user_storage = {} + @users.each do |u| + @user_storage[u.uuid] ||= {} + storage_log = Log. + # filter([[:object_uuid, '=', u.uuid], + # [:event_type, '=', 'user-storage-report']]) + filter([[:object_uuid, '=', u.uuid], + [:event_type, '=', 'user-storage-report']]). + order(:created_at => :desc). + limit(1) + storage_log.each do |log_entry| + @user_storage[u.uuid] = log_entry['properties'] + end + end + @users = @users.sort_by do |u| + [-@user_storage[u.uuid].values.push(0).inject(:+), u.full_name] + end end def show_pane_list diff --git a/apps/workbench/app/views/users/storage.html.erb b/apps/workbench/app/views/users/storage.html.erb index ffa67003cd..51d0c2e1e3 100644 --- a/apps/workbench/app/views/users/storage.html.erb +++ b/apps/workbench/app/views/users/storage.html.erb @@ -43,6 +43,11 @@ table#users-storage-table .cell-for-span-Last-month { <% end %> + <% [:read_collections_total_bytes, :read_collections_weighted_bytes, :persisted_collections_total_bytes, :persisted_collections_weighted_bytes].each do |key| %> + + <%= @user_storage[user.uuid][key].to_s %> + + <% end %> <% end %> -- 2.30.2