Apply automatic rubocop fixes
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ExternalUsersController < ApplicationController
|
||||
before_action :require_user!
|
||||
|
||||
@ -17,8 +19,8 @@ class ExternalUsersController < ApplicationController
|
||||
authorize!
|
||||
end
|
||||
|
||||
def working_time_query(tag=nil)
|
||||
"""
|
||||
def working_time_query(tag = nil)
|
||||
"
|
||||
SELECT user_id,
|
||||
bar.exercise_id,
|
||||
max(score) as maximum_score,
|
||||
@ -43,16 +45,16 @@ class ExternalUsersController < ApplicationController
|
||||
FROM submissions
|
||||
WHERE user_id = #{@user.id}
|
||||
AND user_type = 'ExternalUser'
|
||||
#{!current_user.admin? ? "AND study_group_id IN (#{current_user.study_groups.pluck(:id).join(', ')}) AND cause = 'submit'" : ''}
|
||||
#{current_user.admin? ? '' : "AND study_group_id IN (#{current_user.study_groups.pluck(:id).join(', ')}) AND cause = 'submit'"}
|
||||
GROUP BY exercise_id,
|
||||
user_id,
|
||||
id
|
||||
) AS foo
|
||||
) AS bar
|
||||
#{tag.nil? ? '' : ' JOIN exercise_tags et ON et.exercise_id = bar.exercise_id AND et.tag_id = ' + tag + ' '}
|
||||
#{tag.nil? ? '' : " JOIN exercise_tags et ON et.exercise_id = bar.exercise_id AND et.tag_id = #{tag} "}
|
||||
GROUP BY user_id,
|
||||
bar.exercise_id;
|
||||
"""
|
||||
"
|
||||
end
|
||||
|
||||
def statistics
|
||||
@ -62,11 +64,11 @@ class ExternalUsersController < ApplicationController
|
||||
statistics = {}
|
||||
|
||||
ApplicationRecord.connection.execute(working_time_query(params[:tag])).each do |tuple|
|
||||
statistics[tuple["exercise_id"].to_i] = tuple
|
||||
statistics[tuple['exercise_id'].to_i] = tuple
|
||||
end
|
||||
|
||||
render locals: {
|
||||
statistics: statistics
|
||||
statistics: statistics,
|
||||
}
|
||||
end
|
||||
|
||||
@ -75,15 +77,15 @@ class ExternalUsersController < ApplicationController
|
||||
authorize!
|
||||
|
||||
statistics = []
|
||||
tags = ProxyExercise.new().get_user_knowledge_and_max_knowledge(@user, @user.participations.uniq.compact)
|
||||
tags = ProxyExercise.new.get_user_knowledge_and_max_knowledge(@user, @user.participations.uniq.compact)
|
||||
tags[:user_topic_knowledge].each_pair do |tag, value|
|
||||
statistics.append({key: tag.name.to_s, value: (100.0 / tags[:max_topic_knowledge][tag] * value).round, id: tag.id})
|
||||
statistics.append({key: tag.name.to_s, value: (100.0 / tags[:max_topic_knowledge][tag] * value).round,
|
||||
id: tag.id})
|
||||
end
|
||||
statistics.sort_by! {|item| -item[:value]}
|
||||
statistics.sort_by! {|item| -item[:value] }
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render(json: statistics) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user