You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
658 B
32 lines
658 B
class StatisticsController < ApplicationController
|
|
def index; end
|
|
|
|
def grade
|
|
@services = Analysis.where(service: params.fetch(:service))
|
|
|
|
respond_to do |format|
|
|
format.html
|
|
format.json do
|
|
grades = Hash.new 0
|
|
|
|
@services.each do |service|
|
|
if (result = service.result)
|
|
result.each do |r|
|
|
next unless (grade = r['grade'])
|
|
grades[grade] += 1
|
|
end
|
|
end
|
|
end
|
|
|
|
json = {
|
|
grades: {
|
|
labels: grades.keys,
|
|
dataset: grades
|
|
}
|
|
}
|
|
|
|
render json: json, status: :ok
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|