Parallelize calculation of working_times
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
module ActionCableHelper
|
module ActionCableHelper
|
||||||
def trigger_rfc_action_cable
|
def trigger_rfc_action_cable
|
||||||
|
Thread.new do
|
||||||
# Context: RfC
|
# Context: RfC
|
||||||
if submission.study_group_id.present?
|
if submission.study_group_id.present?
|
||||||
ActionCable.server.broadcast(
|
ActionCable.server.broadcast(
|
||||||
@ -10,6 +11,7 @@ module ActionCableHelper
|
|||||||
locals: {request_for_comment: self})))
|
locals: {request_for_comment: self})))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def trigger_rfc_action_cable_from_comment
|
def trigger_rfc_action_cable_from_comment
|
||||||
# Context: Comment
|
# Context: Comment
|
||||||
@ -17,6 +19,7 @@ module ActionCableHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def trigger_working_times_action_cable
|
def trigger_working_times_action_cable
|
||||||
|
Thread.new do
|
||||||
# Context: Submission
|
# Context: Submission
|
||||||
if study_group_id.present?
|
if study_group_id.present?
|
||||||
ActionCable.server.broadcast(
|
ActionCable.server.broadcast(
|
||||||
@ -25,6 +28,7 @@ module ActionCableHelper
|
|||||||
working_time_data: exercise.get_working_times_for_study_group(study_group_id, user))
|
working_time_data: exercise.get_working_times_for_study_group(study_group_id, user))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Check if any user is connected and prevent preparing the data otherwise
|
# TODO: Check if any user is connected and prevent preparing the data otherwise
|
||||||
|
@ -198,7 +198,7 @@ class Exercise < ApplicationRecord
|
|||||||
def get_working_times_for_study_group(study_group_id, user = nil)
|
def get_working_times_for_study_group(study_group_id, user = nil)
|
||||||
user_progress = []
|
user_progress = []
|
||||||
additional_user_data = []
|
additional_user_data = []
|
||||||
max_bucket = 4
|
max_bucket = 100
|
||||||
maximum_score = self.maximum_score
|
maximum_score = self.maximum_score
|
||||||
|
|
||||||
if user.blank?
|
if user.blank?
|
||||||
@ -209,7 +209,7 @@ class Exercise < ApplicationRecord
|
|||||||
|
|
||||||
results = self.class.connection.execute(study_group_working_time_query(id, study_group_id, additional_filter)).each do |tuple|
|
results = self.class.connection.execute(study_group_working_time_query(id, study_group_id, additional_filter)).each do |tuple|
|
||||||
if tuple['score'] <= maximum_score
|
if tuple['score'] <= maximum_score
|
||||||
bucket = tuple['score'] / maximum_score * max_bucket
|
bucket = (tuple['score'] / maximum_score * max_bucket).round
|
||||||
else
|
else
|
||||||
bucket = max_bucket # maximum_score / maximum_score will always be 1
|
bucket = max_bucket # maximum_score / maximum_score will always be 1
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user