From fc3e9ed4704dc6d64781a4bb3139558f135f1142 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 3 Aug 2018 13:20:31 +0200 Subject: [PATCH] Enable guessing the anomaly notification that triggered the user feedback --- app/models/user_exercise_feedback.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/user_exercise_feedback.rb b/app/models/user_exercise_feedback.rb index 5694573b..3075b96e 100644 --- a/app/models/user_exercise_feedback.rb +++ b/app/models/user_exercise_feedback.rb @@ -9,4 +9,9 @@ class UserExerciseFeedback < ActiveRecord::Base def to_s "User Exercise Feedback" end + + def anomaly_notification + AnomalyNotification.where({exercise_id: exercise.id, user_id: user_id, user_type: user_type}) + .where("created_at < ?", created_at).order("created_at DESC").to_a.first + end end