From 293b6924e9758725b521edc1d667f3abe76efe82 Mon Sep 17 00:00:00 2001 From: Andrew Cain Date: Fri, 14 Jun 2024 11:01:58 +1000 Subject: [PATCH 1/4] chore: ensure lf file endings --- .gitattributes | 2 ++ .gitignore | 1 - .vscode/settings.json | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .vscode/settings.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..d56abbf30 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 481e82b6c..3ef1f7a03 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,4 @@ student-work/ .idea/ .byebug_history coverage/ -.vscode _history diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..7e6882bfa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "files.eol": "\n" +} From 69ef185b368ac27648c5378b182b13b85fb0f7aa Mon Sep 17 00:00:00 2001 From: amriith Date: Wed, 26 Mar 2025 13:29:20 +1100 Subject: [PATCH 2/4] fix(task): resolve feedback notification issue Fixed an issue where feedback notifications were not sent when task status updated. Now, emails are correctly triggered based on status changes. --- Gemfile.lock | 4 ++++ app/api/users_api.rb | 4 ++-- app/models/task.rb | 15 +++++++++++++++ config/environments/development.rb | 23 +++++++++++++++-------- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 58ca5d592..000d70b11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,6 +168,7 @@ GEM faraday-net_http (3.1.0) net-http ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-x86_64-linux-gnu) fugit (1.11.0) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) @@ -265,6 +266,8 @@ GEM nio4r (2.7.3) nokogiri (1.16.5-aarch64-linux) racc (~> 1.4) + nokogiri (1.16.5-x86_64-linux) + racc (~> 1.4) observer (0.1.2) orm_adapter (0.5.0) parallel (1.24.0) @@ -490,6 +493,7 @@ GEM PLATFORMS aarch64-linux + x86_64-linux DEPENDENCIES better_errors diff --git a/app/api/users_api.rb b/app/api/users_api.rb index ffcf6a42f..21a21692f 100644 --- a/app/api/users_api.rb +++ b/app/api/users_api.rb @@ -67,8 +67,8 @@ class UsersApi < Grape::API change_self = (params[:id] == current_user.id) params[:receive_portfolio_notifications] = true if params.key?(:receive_portfolio_notifications) && params[:receive_portfolio_notifications].nil? - params[:receive_portfolio_notifications] = true if params.key?(:receive_feedback_notifications) && params[:receive_feedback_notifications].nil? - params[:receive_portfolio_notifications] = true if params.key?(:receive_task_notifications) && params[:receive_task_notifications].nil? + params[:receive_feedback_notifications] = true if params.key?(:receive_feedback_notifications) && params[:receive_feedback_notifications].nil? + params[:receive_task_notifications] = true if params.key?(:receive_task_notifications) && params[:receive_task_notifications].nil? # can only modify if current_user.id is same as :id provided # (i.e., user wants to update their own data) or if update_user token diff --git a/app/models/task.rb b/app/models/task.rb index e75815f90..211a18235 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -132,6 +132,7 @@ def specific_permission_hash(role, perm_hash, _other) delegate :update_task_stats, to: :project after_update :update_task_stats, if: :saved_change_to_task_status_id? # TODO: consider moving to async task + after_update :send_feedback_notification, if: :saved_change_to_task_status_id? validates :task_definition_id, uniqueness: { scope: :project, message: 'must be unique within the project' } @@ -1362,6 +1363,20 @@ def read_file_from_done(idx) nil end + def send_feedback_notification + return unless task_status.in?([TaskStatus.redo, TaskStatus.fail, TaskStatus.fix_and_resubmit, TaskStatus.feedback_exceeded, TaskStatus.discuss, TaskStatus.demonstrate, TaskStatus.complete]) + return unless project.student.receive_feedback_notifications + return unless unit.send_notifications + + begin + logger.info "Checking feedback email for project #{project.id}" + logger.info "Emailing feedback notification to #{project.student.name}" + PortfolioEvidenceMailer.task_feedback_ready(project, [self]).deliver + rescue => e + logger.error "Failed to send feedback notification email. Error: #{e.message}" + end + end + private def delete_associated_files diff --git a/config/environments/development.rb b/config/environments/development.rb index 0b4ebb164..d0e4e1214 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -53,14 +53,21 @@ # Store uploaded files on the local file system (see config/storage.yml for options). # config.active_storage.service = :local - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # Write them to file instead (under doubtfire-api/tmp/mails) - config.action_mailer.delivery_method = :file + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = true + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # Write them to file instead (under doubtfire-api/tmp/mails) + config.action_mailer.delivery_method = :file + config.action_mailer.file_settings = { + :location => File.join(Rails.root, 'tmp', 'mails') + } + + # Add more verbose logging for ActionMailer + config.action_mailer.logger = Logger.new(STDOUT) + config.action_mailer.logger.level = Logger::DEBUG # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log From 16373efb651ebe3d2bb6cdeda38a64ddabcb5264 Mon Sep 17 00:00:00 2001 From: Amrith Jayadeep <83343585+amriith@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:30:08 +1100 Subject: [PATCH 3/4] Update app/models/task.rb Co-authored-by: Martin Dolores <77220115+martindolores@users.noreply.github.com> --- app/models/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/task.rb b/app/models/task.rb index 211a18235..9900f0761 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1366,7 +1366,7 @@ def read_file_from_done(idx) def send_feedback_notification return unless task_status.in?([TaskStatus.redo, TaskStatus.fail, TaskStatus.fix_and_resubmit, TaskStatus.feedback_exceeded, TaskStatus.discuss, TaskStatus.demonstrate, TaskStatus.complete]) return unless project.student.receive_feedback_notifications - return unless unit.send_notifications + return unless unit&.send_notifications begin logger.info "Checking feedback email for project #{project.id}" From fefd1410455be67bc4e869c5ad6328cee3c21cd0 Mon Sep 17 00:00:00 2001 From: Amrith Jayadeep <83343585+amriith@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:13:22 +1100 Subject: [PATCH 4/4] Update development.rb --- config/environments/development.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index d0e4e1214..e9be2ded6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -54,20 +54,14 @@ # config.active_storage.service = :local # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = true + + config.action_mailer.raise_delivery_errors = false - config.action_mailer.perform_caching = false + config.action_mailer.perform_caching = false - # Tell Action Mailer not to deliver emails to the real world. - # Write them to file instead (under doubtfire-api/tmp/mails) - config.action_mailer.delivery_method = :file - config.action_mailer.file_settings = { - :location => File.join(Rails.root, 'tmp', 'mails') - } - - # Add more verbose logging for ActionMailer - config.action_mailer.logger = Logger.new(STDOUT) - config.action_mailer.logger.level = Logger::DEBUG + # Tell Action Mailer not to deliver emails to the real world. + # Write them to file instead (under doubtfire-api/tmp/mails) + config.action_mailer.delivery_method = :file # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log