Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor notification #184

Merged
merged 22 commits into from
Feb 5, 2024
Merged

refactor notification #184

merged 22 commits into from
Feb 5, 2024

Conversation

alexskr
Copy link
Member

@alexskr alexskr commented Feb 2, 2024

notification refactor follow up to #148

  • Rename variables and methods to make a clear distinction between
    OntoPortal site admins, ontology admins and support.
  • Add new feature to optionally disable notifications send to OntoPortal
    admins for each event associated with ontology creation, new user, etc
  • LinkedData.setting.support_contact_email is a new configuration option
    for setting end user support contact email.
    BioPortal requires different emails for contacting BioPortal site
    admins and end user support

In order to clarify the distinction between the OntoPortal site admins and
ontology owners/admins the following settings and methods are renamed:

LinkedData.setting.admin_emails is renamed to ontoportal_admin_emails
LinkedData::Utils::Notifier.admin_mails -> ontology_admin_emails
LinkedData::Utils::support_mails -> ontoportal_admin_emails
LinkedData::Utils::notify_support_grouped -> notify_ontoportal_admins_grouped

syphax-bouazzouni and others added 20 commits April 4, 2022 14:30
- Rename variables and methods to make a clear distinction between
  OntoPortal site admins, ontology admins and support.
- Add new feature to optionally disable notifications send to OntoPortal
  admins for each event associated with ontology creation, new user, etc
- LinkedData.setting.support_contact_email is a new configuration option
  for setting end user support contact email.
  BioPortal requires different emails for contacting BioPortal site
  admins and end user support

In order to clarify the distinction between the OntoPortal site admins and
ontology owners/admins the following settings and methods are renamed:

LinkedData.setting.admin_emails is renamed to ontoportal_admin_emails
LinkedData::Utils::Notifier.admin_mails -> ontology_admin_emails
LinkedData::Utils::support_mails -> ontoportal_admin_emails
LinkedData::Utils::notify_support_grouped -> notify_ontoportal_admins_grouped
@alexskr
Copy link
Member Author

alexskr commented Feb 2, 2024

@syphax-bouazzouni please review the follow up changes and let me know if there is anything that should be tweaked in order to fit your code base

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 30 lines in your changes are missing coverage. Please review.

Comparison is base (4b6b7f4) 80.76% compared to head (d0b6ad8) 80.66%.
Report is 4 commits behind head on develop.

❗ Current head d0b6ad8 differs from pull request most recent head 87afcc4. Consider uploading reports for the commit 87afcc4 to get more accurate results

Files Patch % Lines
lib/ontologies_linked_data/utils/notifications.rb 61.97% 27 Missing ⚠️
lib/ontologies_linked_data/utils/notifier.rb 94.82% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #184      +/-   ##
===========================================
- Coverage    80.76%   80.66%   -0.10%     
===========================================
  Files           63       64       +1     
  Lines         4917     5337     +420     
===========================================
+ Hits          3971     4305     +334     
- Misses         946     1032      +86     
Flag Coverage Δ
unittests 80.66% <76.92%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@syphax-bouazzouni syphax-bouazzouni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey 👋 , thanks on working on this. Fine by me.
Added some optional minor remarks that you can

puts "Error: 'redis_host' is not a valid conf parameter."
puts ' Redis databases were split into multiple hosts (09/22/13).'
raise Exception, 'redis_host is not a valid conf parameter.'
unless @settings.admin_emails.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this part?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin_emails setting was renamed to ontoportal_admin_emails so thats a way to notify folks who have been relying on that setting to update. I would be more than happy to remove if you think thats an overkill.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is overkill, this sort of code, is always the one remaining 10 years after, with no one knowing why they are here and too screed to remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in 87afcc4

@@ -69,7 +65,8 @@ def config(&block)

# Email settings
@settings.enable_notifications ||= false
@settings.email_sender ||= '[email protected]' # Default sender for emails
# Default sender From email address
@settings.email_sender ||= '[email protected]'
@settings.email_override ||= '[email protected]' # By default, all email gets sent here. Disable with email_override_disable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email_override and email_disable_override are never really used, in test or development environments config the email_sender on it self is email_override

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use email_override in staging environment to troubleshoot send notifications to a dedicated email address used for debugging only. Sending all overwritten/debugging emails to the admin account creates too much noise so having this options works well for us.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but I mean in your staging env, you can set admin_email as the one that you override with ? anyways no big deal.


def self.ontoportal_admin_emails

if !LinkedData.settings.ontoportal_admin_emails.nil? &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition can be replaced with only, which handle nil case also

 LinkedData.settings.ontoportal_admin_emails.is_a?(Array) 

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or all the function by Array(LinkedData.settings.ontoportal_admin_emails)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in d0b6ad8

end
recipients
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add (and use) the following helper/facets/alias here

def self.support_mail
 Array(LinkedData.settings.support_contact_email)
end
def self.notification_enabled?
   LinkedData.settings.enable_administrative_notifications
end 

this will make it easier to read

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion

addressed in d0b6ad8

end

def self.notify_ontoportal_admins(subject, body)
notify_mails_grouped subject, body, ontoportal_admin_emails if LinkedData.settings.enable_administrative_notifications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of the if LinkedData.settings.enable_administrative_notifications as notify already test that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinkedData.settings.enable_administrative_notifications is not the same as LinkedData.settings.enable_notifications

enable_notifications enables all notifications for all users
enable_administrative_notifications enables notifications send to the admin team (or support team in your case) for things like new user creation event. BioPortal team doesn't have the need to see those notifications.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok sorry, miss reading the thing,
Good for me

end

def self.notify_ontoportal_admins_grouped(subject, body)
notify_mails_grouped subject, body, ontoportal_admin_emails if LinkedData.settings.enable_administrative_notifications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of the if LinkedData.settings.enable_administrative_notifications as notify already test that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants