Skip to content

Commit

Permalink
Using timezone to generate timeline dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Smith committed Oct 13, 2010
1 parent be5418a commit 9546274
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/dashboard_controller.rb
Expand Up @@ -7,7 +7,7 @@ def index
@closed_tickets = Ticket.closed_tickets

# create array of date strings from 30 days ago up to yesterday
@timeline = ((Date.parse 30.days.ago.to_s)..(Date.yesterday)).inject([]){ |accum, date| accum << date.to_s }
@timeline = ((Time.zone.now - 30.days).to_date..(Time.zone.now - 1.day).to_date).inject([]){ |accum, date| accum << date.to_s }

@timeline_opened_tickets = Ticket.timeline_opened_tickets
@timeline_closed_tickets = Ticket.timeline_closed_tickets
Expand Down
4 changes: 2 additions & 2 deletions app/models/ticket.rb
Expand Up @@ -25,11 +25,11 @@ class Ticket < ActiveRecord::Base
named_scope :closed_tickets, :limit => 5, :joins => :status, :include => [:creator, :owner, :group, :status, :priority], :conditions => ['statuses.name = ?', 'Closed'], :order => 'closed_at DESC'

def self.timeline_opened_tickets
self.count(:group => 'date(created_at)', :having => ['date_created_at >= ? and date_created_at <= ?', (Time.zone.now.beginning_of_day - 30.days).to_s, (Time.zone.now.end_of_day - 1.day).to_s])
self.count(:group => 'created_at', :having => ['created_at >= ? and created_at <= ?', (Time.zone.now.beginning_of_day - 30.days).to_s, (Time.zone.now.end_of_day - 1.day).to_s])
end

def self.timeline_closed_tickets
self.count(:group => 'date(closed_at)', :having => ['date_closed_at >= ? and date_closed_at <= ?', (Time.zone.now.beginning_of_day - 30.days).to_s, (Time.zone.now.end_of_day - 1.day).to_s])
self.count(:group => 'closed_at', :having => ['closed_at >= ? and closed_at <= ?', (Time.zone.now.beginning_of_day - 30.days).to_s, (Time.zone.now.end_of_day - 1.day).to_s])
end

def closed?
Expand Down

0 comments on commit 9546274

Please sign in to comment.