Class: Houston::Roadmaps::DashboardController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/houston/roadmaps/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/houston/roadmaps/dashboard_controller.rb', line 7

def show
  if params.key?(:range)
    start_date, end_date = params[:range]
      .split(/\.{2,}/)
      .map { |date| Date.strptime(date, "%Y-%m-%d") }
    @range = start_date..end_date
  else
    today = Date.today
    @range = 6.months.before(today)..6.months.after(today)
  end

  @milestones = RoadmapMilestone.during(@range).preload(:milestone => :project)

  @show_today = params[:today] != "false"

  @title = "Roadmap"
  respond_to do |format|
    format.html { render }
    format.json { render json: {
      range: {start: @range.begin, end: @range.end},
      milestones: Houston::Roadmaps::RoadmapMilestonePresenter.new(@milestones) } }
  end
end