Made sizes human readable, added measurement date column.
authorMisha Zatsman <misha-arvados@zatsman.com>
Wed, 23 Apr 2014 20:14:38 +0000 (20:14 +0000)
committerMisha Zatsman <misha-arvados@zatsman.com>
Wed, 23 Apr 2014 20:14:38 +0000 (20:14 +0000)
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/users/storage.html.erb

index 72d44f51c2b27d36b8f12c8d359308b5d3500ecf..53f3d3912f59dcaed0bfd46738def408502cf444 100644 (file)
@@ -67,22 +67,21 @@ class UsersController < ApplicationController
     @breadcrumb_page_name = nil
     @users = User.limit(params[:limit] || 1000).all
     @user_storage = {}
+    @log_date = {}
     @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']
+        @log_date[u.uuid] = log_entry['event_at']
       end
     end
-    @users = @users.sort_by do |u|
-      [-@user_storage[u.uuid].values.push(0).inject(:+), u.full_name]
-    end
+    @users = @users.sort_by { |u|
+      [-@user_storage[u.uuid].values.push(0).inject(:+), u.full_name]}
   end
 
   def show_pane_list
index 51d0c2e1e3986cea501c9dc3d68f30c66d16aba2..99c8883c2a2766e18957976042b0cf2adf7e29cc 100644 (file)
@@ -1,15 +1,15 @@
 <% content_for :css do %>
 table#users-storage-table th {
     overflow-x: hidden;
+    text-align: center;
 }
-table#users-storage-table .cell-for-span-This-month,
-table#users-storage-table .cell-for-span-Last-month {
-    background: #eee;
+table#users-storage-table .byte-value {
+    text-align: right;
 }
 <% end %>
 <table class="table table-condensed arv-index" id="users-storage-table">
   <colgroup>
-    <col width="28%" />
+    <col />
   </colgroup>
 
   <tr>
@@ -20,13 +20,14 @@ table#users-storage-table .cell-for-span-Last-month {
     <th colspan="2">
       Collections Persisted Storage
     </th>
+    <th rowspan="2">Measured At</th>
   </tr>
   <tr>
     <% 2.times do %>
-    <th>
+    <th class="byte-value">
       Total (unweighted)
     </th>
-    <th>
+    <th class="byte-value">
       Shared (weighted)
     </th>
     <% end %>
@@ -44,10 +45,13 @@ table#users-storage-table .cell-for-span-Last-month {
       </small>
     </td>
     <% [:read_collections_total_bytes, :read_collections_weighted_bytes, :persisted_collections_total_bytes, :persisted_collections_weighted_bytes].each do |key| %>
-    <td>
-      <%= @user_storage[user.uuid][key].to_s %>
+    <td class="byte-value">
+      <%= human_readable_bytes_html(@user_storage[user.uuid].fetch(key,0).floor) %>
     </td>
     <% end %>
+    <td class="date">
+      <%= @log_date[user.uuid] %>
+    </td>
   </tr>
   <% end %>
 </table>