aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-12-04 09:10:03 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-12-04 09:10:03 +0000
commitff17da300f361425f0e22ccd9066cb6577aa10ee (patch)
treeec220c3bfdd7cd105d4ba2695fe1608cd44ec331
parent66d2bcbfb05499ed4a185b0dff0829c8c49f4d08 (diff)
Fixed event views to use dates, and to miss queries for days with no events.
-rw-r--r--lib/mauve/web_interface.rb4
-rw-r--r--views/_events_calendar_day.haml6
-rw-r--r--views/_history.haml2
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb
index c6de5ff..5bb339a 100644
--- a/lib/mauve/web_interface.rb
+++ b/lib/mauve/web_interface.rb
@@ -528,13 +528,13 @@ EOF
query[:history][:created_at.gte] = Time.local(today.year, today.month, today.day, 0, 0, 0)
query[:history][:created_at.lt] = Time.local(tomorrow.year, tomorrow.month, tomorrow.day, 0, 0, 0)
- events = AlertHistory.all(formulate_events_query(query)).history
+ events = AlertHistory.all(formulate_events_query(query))
event_week = ((today - start)/7).floor
event_day = (today.wday == 0 ? 6 : (today.wday - 1))
@events_by_week[event_week] ||= Array.new(7) { Array.new }
- @events_by_week[event_week][event_day] = events
+ @events_by_week[event_week][event_day] = (events.count == 0 ? [] : events.history)
today = tomorrow
end
diff --git a/views/_events_calendar_day.haml b/views/_events_calendar_day.haml
index fa0c517..712559c 100644
--- a/views/_events_calendar_day.haml
+++ b/views/_events_calendar_day.haml
@@ -1,8 +1,8 @@
%td{:class => (@today.month % 2 == 0 ? "even" : "odd")}
%p.event_date
%a{:href => "/events/list/#{@today.strftime("%F")}?#{request.query_string}"}
- = @today.strftime(((@today - 1).month != @today.month) ? "%d %b" : "%d")
- =partial("history", :collection => events_calendar_day.last(10).to_a.reverse)
+ = @today.strftime((@today.day == 1) ? "%d %b" : "%d")
+ =partial("history", :collection => events_calendar_day.last(10).alerts.to_a.reverse)
%p
- n_events = events_calendar_day.count
- if n_events > 10
@@ -12,4 +12,4 @@
- if n_events > 0
%a{:href => "/events/list/#{@today.strftime("%F")}?#{request.query_string}"}
Show the whole day.
- - @today += 1
+- @today = @today + 1
diff --git a/views/_history.haml b/views/_history.haml
index cfeec51..400c1c3 100644
--- a/views/_history.haml
+++ b/views/_history.haml
@@ -14,4 +14,4 @@
= history.event
- if history.user
= "by #{history.user}"
- - @today = history.created_at
+ - @today = Date.new(history.created_at.year, history.created_at.month, history.created_at.day)