diff --git a/app/models/proxy_exercise.rb b/app/models/proxy_exercise.rb index f731aa61..84f5e487 100644 --- a/app/models/proxy_exercise.rb +++ b/app/models/proxy_exercise.rb @@ -36,8 +36,23 @@ class ProxyExercise < ActiveRecord::Base Rails.logger.debug("retrieved assigned exercise for user #{user.id}: Exercise #{assigned_user_proxy_exercise.exercise}" ) assigned_user_proxy_exercise.exercise else - Rails.logger.debug("find new matching exercise for user #{user.id}" ) matching_exercise = + if (token.eql? "47f4c736") + Rails.logger.debug("Proxy exercise with token 47f4c736, split user in groups..") + group = UserGroupSeparator.getGroupWeek2Testing(user) + Rails.logger.debug("user assigned to group #{group}") + case group + when :group_a + exercises.where(id: 348).first + when :group_b + exercises.where(id: 349).first + when :group_c + exercises.where(id: 350).first + when :group_d + exercises.where(id: 351).first + end + else + Rails.logger.debug("find new matching exercise for user #{user.id}" ) begin find_matching_exercise(user) rescue #fallback @@ -46,8 +61,11 @@ class ProxyExercise < ActiveRecord::Base @reason[:error] = "#{$!}" exercises.shuffle.first end + end user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user, exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json) matching_exercise + + end recommended_exercise end diff --git a/lib/user_group_separator.rb b/lib/user_group_separator.rb index 5be05ef6..c49ffe44 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -24,4 +24,17 @@ class UserGroupSeparator end end + def self.getGroupWeek2Testing(user) + groupById = user.id % 4 + if groupById == 0 + :group_a + elsif groupById == 1 + :group_b + elsif groupById == 2 + :group_c + else # 3 + :group_d + end + end + end \ No newline at end of file