Parallelize calculation of working_times

This commit is contained in:
Sebastian Serth
2019-05-08 15:03:38 +02:00
parent 90c89703bb
commit a95b2409d3
2 changed files with 18 additions and 14 deletions

View File

@ -1,5 +1,6 @@
module ActionCableHelper
def trigger_rfc_action_cable
Thread.new do
# Context: RfC
if submission.study_group_id.present?
ActionCable.server.broadcast(
@ -10,6 +11,7 @@ module ActionCableHelper
locals: {request_for_comment: self})))
end
end
end
def trigger_rfc_action_cable_from_comment
# Context: Comment
@ -17,6 +19,7 @@ module ActionCableHelper
end
def trigger_working_times_action_cable
Thread.new do
# Context: Submission
if study_group_id.present?
ActionCable.server.broadcast(
@ -26,5 +29,6 @@ module ActionCableHelper
end
end
end
end
# TODO: Check if any user is connected and prevent preparing the data otherwise

View File

@ -198,7 +198,7 @@ class Exercise < ApplicationRecord
def get_working_times_for_study_group(study_group_id, user = nil)
user_progress = []
additional_user_data = []
max_bucket = 4
max_bucket = 100
maximum_score = self.maximum_score
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|
if tuple['score'] <= maximum_score
bucket = tuple['score'] / maximum_score * max_bucket
bucket = (tuple['score'] / maximum_score * max_bucket).round
else
bucket = max_bucket # maximum_score / maximum_score will always be 1
end