Class: Bible270::DaysController
Constant Summary
ApplicationController::REMEMBER_COOKIE
Instance Method Summary
collapse
Instance Method Details
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/bible270/days_controller.rb', line 5
def index
@plan_totals = Plan.totals
@readers = Reader.order(updated_at: :desc).to_a
counts = Checkoff.group(:reader_id, :day).count
@days_completed = Hash.new(0)
counts.each { |(rid, day), n| @days_completed[rid] += 1 if n >= Plan.total_parts(day) }
@readers = @readers.sort_by { |r| -@days_completed[r.id] }
@start_day = current_reader&.current_day || 1
@today_day = current_reader&.today_day
@community_start_date = Bible270.config.start_date
@allow_reader_start_date = Bible270.config.allow_reader_start_date
end
|
#show ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/bible270/days_controller.rb', line 22
def show
@day = params[:day].to_i
redirect_to(root_path, alert: 'That day is outside the plan.') and return unless Plan.valid_day?(@day)
@readings = Plan.readings_for(@day)
@comments = Comment.for_day(@day).includes(:reader)
@new_comment = Comment.new(day: @day)
@reader_tracks = current_reader ? current_reader.read_tracks_for(@day) : []
required = Plan.total_parts(@day)
completer_ids = Checkoff.where(day: @day)
.group(:reader_id)
.having('COUNT(*) >= ?', required)
.pluck(:reader_id)
@completers = Reader.where(id: completer_ids).order(:display_name)
@prev_day = @day > 1 ? @day - 1 : nil
@next_day = @day < Plan::DAYS ? @day + 1 : nil
end
|