diff --git a/app/helpers/action_cable_helper.rb b/app/helpers/action_cable_helper.rb index 4c22424c..4422a7cb 100644 --- a/app/helpers/action_cable_helper.rb +++ b/app/helpers/action_cable_helper.rb @@ -1,15 +1,17 @@ module ActionCableHelper - def trigger_rfc_action_cable +def trigger_rfc_action_cable + Thread.new do # Context: RfC if submission.study_group_id.present? ActionCable.server.broadcast( - "la_exercises_#{exercise_id}_channel_study_group_#{submission.study_group_id}", - type: :rfc, - id: id, - html: (ApplicationController.render(partial: 'request_for_comments/list_entry', - locals: {request_for_comment: self}))) + "la_exercises_#{exercise_id}_channel_study_group_#{submission.study_group_id}", + type: :rfc, + id: id, + html: (ApplicationController.render(partial: 'request_for_comments/list_entry', + locals: {request_for_comment: self}))) end end +end def trigger_rfc_action_cable_from_comment # Context: Comment @@ -17,12 +19,14 @@ module ActionCableHelper end def trigger_working_times_action_cable - # Context: Submission - if study_group_id.present? - ActionCable.server.broadcast( - "la_exercises_#{exercise_id}_channel_study_group_#{study_group_id}", - type: :working_times, - working_time_data: exercise.get_working_times_for_study_group(study_group_id, user)) + Thread.new do + # Context: Submission + if study_group_id.present? + ActionCable.server.broadcast( + "la_exercises_#{exercise_id}_channel_study_group_#{study_group_id}", + type: :working_times, + working_time_data: exercise.get_working_times_for_study_group(study_group_id, user)) + end end end end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 673903b6..68465934 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -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