Fix up start/end dates and display them in a more friendly way.
authorTom Clegg <tom@curoverse.com>
Mon, 10 Mar 2014 15:14:49 +0000 (11:14 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 10 Mar 2014 15:14:49 +0000 (11:14 -0400)
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/users/activity.html.erb

index 927637f65d010cdf6f33a6972f909999ad605d9a..6168cd52931c302a8099195cc6f481759c9133e7 100644 (file)
@@ -19,14 +19,13 @@ class UsersController < ApplicationController
       pipeline_instances: {}
     }
     @spans = [['This week', Time.now.beginning_of_week, Time.now],
-              ['Last week', 1.week.ago.beginning_of_week, nil],
+              ['Last week',
+               Time.now.beginning_of_week.advance(weeks:-1),
+               Time.now.beginning_of_week],
               ['This month', Time.now.beginning_of_month, Time.now],
-              ['Last month', 1.month.ago.beginning_of_month, nil]].
-      collect do |span|
-      span[2] ||= span[1].advance(months: 1) if span[0].match /month/
-      span[2] ||= span[1].advance(weeks: 1) if span[0].match /week/
-      span
-    end
+              ['Last month',
+               1.month.ago.beginning_of_month,
+               Time.now.beginning_of_month]]
     @spans.each do |span, threshold_start, threshold_end|
       @activity[:logins][span] = Log.
         filter([[:event_type, '=', 'login'],
index 619081ff6f73847f89171e13360611fcef219738..4517b7d57ca3de180e071db42ff7728a3fb1e518 100644 (file)
@@ -18,7 +18,13 @@ table#users-activity-table th {
   <tr>
     <th rowspan="2">User</th>
     <% @spans.each do |span, start_at, end_at| %>
-    <th colspan="3" title="<%= start_at.to_s.sub(/ .*/, '') %> to <%= (end_at-1.second).to_s.sub(/ .*/, '') %>"><%= span %></th>
+    <th colspan="3">
+      <%= span %>
+      <br />
+      <%= start_at.strftime('%b %-d') %>
+      -
+      <%= (end_at-1.second).strftime('%b %-d') %>
+    </th>
     <% end %>
   </tr>
   <tr>