Class: SnitchReporting::SnitchReportsController
Instance Method Summary
collapse
#sort_order, #sortable, #svg, #toggled_sort_order, #true_param?, #truthy?
Instance Method Details
#index ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/controllers/snitch_reporting/snitch_reports_controller.rb', line 9
def index
@reports = ::SnitchReporting::SnitchReport.order("last_occurrence_at DESC NULLS LAST").page(params[:page]).per(params[:per] || 25)
filter_reports
end
|
#show ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/snitch_reporting/snitch_reports_controller.rb', line 17
def show
@report = ::SnitchReporting::SnitchReport.find(params[:id])
occurrences = @report.occurrences.order(created_at: :asc)
@occurrence = occurrences.find_by(id: params[:occurrence]) || occurrences.last
occurrence_ids = occurrences.ids
occurrence_idx = occurrence_ids.index(@occurrence.id)
@paged_ids = {
first: occurrence_idx == 0 ? nil : occurrence_ids.first,
prev: occurrence_idx == 0 ? nil : occurrence_ids[occurrence_idx - 1],
next: occurrence_idx == occurrence_ids.length - 1 ? nil : occurrence_ids[occurrence_idx + 1],
last: occurrence_idx == occurrence_ids.length - 1 ? nil : occurrence_ids.last,
}
end
|
#update ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/snitch_reporting/snitch_reports_controller.rb', line 34
def update
@report = ::SnitchReporting::SnitchReport.find(params[:id])
@report.update(report_params)
respond_to do |format|
format.html { redirect_to @report }
format.json
end
end
|