BathHacked/energy-sparks

View on GitHub
app/controllers/schools/annotations_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
module Schools
  class AnnotationsController < ApplicationController
    skip_before_action :authenticate_user!

    def show
      @school = School.find(params[:school_id])
      annotator = Charts::Annotate.new(school: @school, fuel_types: [params['fuel_type']])

      @annotations = case params[:date_grouping]
                     when 'weekly' then annotator.annotate_weekly(params[:x_axis_categories])
                     when 'daily' then annotator.annotate_daily(params[:x_axis_start], params[:x_axis_end])
                     else []
                     end
    end
  end
end