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

Bump noticed from 1.6.3 to 2.3.2 #6889

Merged
merged 26 commits into from
Jun 20, 2024
Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Jun 3, 2024

Bumps noticed from 1.6.3 to 2.3.2.

Release notes

Sourced from noticed's releases.

v2.3.2

What's Changed

Full Changelog: excid3/noticed@v2.3.1...v2.3.2

v2.3.1

Full Changelog: excid3/noticed@v2.3.0...v2.3.1

v2.3.0

What's Changed

New Contributors

Full Changelog: excid3/noticed@v2.2.2...v2.3.0

v2.2.2

Full Changelog: excid3/noticed@v2.2.1...v2.2.2

v2.2.1

What's Changed

  • Support procs and symbol method calls with fetch_constant helpers
  • Use 'attributes[:params]' instead of 'params' in the example about migrating associated records in UPGRADE.md by @​drjole in excid3/noticed#427

New Contributors

Full Changelog: excid3/noticed@v2.2.0...v2.2.1

v2.2.0

What's Changed

... (truncated)

Changelog

Sourced from noticed's changelog.

2.3.2

  • Set :json type on :params column with default to better integrate with ActiveRecord. This fixes sqlserver (and probably other databases). #451

2.3.1

  • Skip ApplicationNotifier in generator if it already exists

2.3.0

  • Add error_handler to Twilio delivery method #444
  • Fix record being removed for Ephemeral notifications #448

2.2.2

  • fetch_constant will now constantize Strings returned from procs or method calls

2.2.1

  • fetch_constant used by Email and ActionCable delivery methods now support procs and method calls with symbols like other options

2.2.0

  • Add config.before_enqueue callback This callback can be used to skip enqueuing delivery methods:
class CommentNotifier < Noticed::Event
  deliver_by :email do |config|
    config.before_enqueue = ->{ throw(:abort) unless recipient.email_notifications? }
  end
end
  • Fix iOS format option with Symbols. This now passes the notification and apn objects instead of just the apn.
config.format = :ios_format
...
def ios_format(notification, apn)
end

  • Re-add deserialize_error? to Noticed::Event

2.1.3

  • Stringify keys for Twilio Messaging json

... (truncated)

Upgrade guide

Sourced from noticed's upgrade guide.

Noticed Upgrade Guide

Follow this guide to upgrade your Noticed implementation to the next version

Noticed 2.1

We've added a counter cache to Noticed::Event to keep track of the associated notifications.

Run the following command to copy over the migrations:

rails noticed:install:migrations

Noticed 2.0

We've made some major changes to Noticed to simplify and support more delivery methods.

Models

Instead of having models live in your application, Noticed v2 adds models managed by the gem.

Delete the Notification model at app/models/notification.rb.

Then run the new migrations:

rails noticed:install:migrations
rails db:migrate

To migrate your data to the new tables, loop through your existing notifications and create new records for each one. You can do this in a Rake task or in the Rails console:

# Temporarily define the Notification model to access the old table
class Notification < ActiveRecord::Base
  self.inheritance_column = nil
end
Migrate each record to the new tables
Notification.find_each do |notification|
attributes = notification.attributes.slice("type", "created_at", "updated_at").with_indifferent_access
attributes[:type] = attributes[:type].sub("Notification", "Notifier")
attributes[:params] = Noticed::Coder.load(notification.params)
attributes[:params] = {} if attributes[:params].try(:has_key?, "noticed_error") # Skip invalid records
Extract related record to belongs_to :record association
This allows ActiveRecord associations instead of querying the JSON data
attributes[:record] = attributes[:params].delete(:user) || attributes[:params].delete(:account)
attributes[:notifications_attributes] = [{
type: "#{attributes[:type]}::Notification",
</tr></table>

... (truncated)

Commits
  • 0430be6 Version bump
  • 6dfb7d9 Add sqlserver support (#451)
  • f52e870 Version bump
  • bc93b64 Skip application notifier if it already exists
  • 5a1fb91 Use matching sqlite3 versions for Rails versions
  • 8e2dc61 Merge branch 'main' of github.com:excid3/noticed
  • 68c406f Version bump
  • 7cb10d1 Update twilio_messaging.md
  • 2ef3c18 Twilio delivery method allows Notifier to handle errors (#444)
  • 2a3dbb0 Don't remove record from params with ephemeral notifications (#448)
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies ruby Pull requests that update Ruby code labels Jun 3, 2024
@dependabot dependabot bot force-pushed the dependabot/bundler/noticed-2.3.2 branch from 505261d to 86d0619 Compare June 10, 2024 09:22
@KyleMacPherson KyleMacPherson force-pushed the dependabot/bundler/noticed-2.3.2 branch from ee6b78d to 1a14633 Compare June 11, 2024 15:00
Copy link
Contributor Author

dependabot bot commented on behalf of github Jun 11, 2024

OK, I won't notify you again about this release, but will get in touch when a new version is available. If you'd rather skip all updates until the next major or minor version, let me know by commenting @dependabot ignore this major version or @dependabot ignore this minor version. You can also ignore all major, minor, or patch releases for a dependency by adding an ignore condition with the desired update_types to your config file.

If you change your mind, just re-open this PR and I'll resolve any conflicts on it.

@KyleMacPherson KyleMacPherson force-pushed the dependabot/bundler/noticed-2.3.2 branch from 1a14633 to 86d0619 Compare June 11, 2024 15:08
@KyleMacPherson KyleMacPherson force-pushed the dependabot/bundler/noticed-2.3.2 branch from 5a379c2 to 8072293 Compare June 17, 2024 10:33
@KyleMacPherson KyleMacPherson force-pushed the dependabot/bundler/noticed-2.3.2 branch from 3f5cb6f to 05930d5 Compare June 17, 2024 13:29
Due to the changes in the gem upgrade the time travel blocks do not work for out purpose in these tests. I believe this is because the noticed event is created inside the time travel block, but that creates noticed notifications in the background outside of the time travel block, so i have stubbed the created_at on the notifications to recreate these tests as best I can.
These specs only test the timestamp method, and are very flaky due to the way the upgrade to the noticed gem works. Now the event is created when the deliver method is run and in turn this created notifications in the background, making these tests are flaky. I think this in combination with how little value these tests add make removing them a sensible idea.
@@ -12,11 +12,11 @@ def index

def notifications
@notifications ||= current_publisher.notifications
.created_within_data_access_period
Copy link
Collaborator

Choose a reason for hiding this comment

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

This scope is on the old notifications model, which will be deleted. It is only referenced here.

.order(created_at: :desc)
end

def mark_notifications_as_read
notifications.mark_as_read!
notifications.mark_as_read
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is because in the new version of noticed mark_as_read! has been renamed to mark_as_read

@@ -1,4 +1,4 @@
class SendJobApplicationDataExpiryNotificationJob < ApplicationJob
class SendJobApplicationDataExpiryNotifierJob < ApplicationJob
Copy link
Collaborator

Choose a reason for hiding this comment

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

In noticed v2 notifiers are the class that delivers notifications Notification - the database record of the notification. They recommend changing the classes to match this.

@@ -3,8 +3,6 @@ class ApplicationRecord < ActiveRecord::Base

before_save :strip_attributes

DATA_ACCESS_PERIOD_FOR_PUBLISHERS = 1.year.freeze
Copy link
Collaborator

Choose a reason for hiding this comment

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

DATA_ACCESS_PERIOD_FOR_PUBLISHERS needs to be available in both controllers and models now so I have added it to a data_access_period initializer.

@@ -0,0 +1 @@
DATA_ACCESS_PERIOD_FOR_PUBLISHERS = 1.year.freeze
Copy link
Collaborator

Choose a reason for hiding this comment

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

DATA_ACCESS_PERIOD_FOR_PUBLISHERS needs to be available in both controllers and models now so I have added it to a data_access_period initializer.

@@ -1,8 +1,7 @@
class Notification < ApplicationRecord
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class needs to remain for now so that we can run the migration to migrate our previous notifications over to the new noticed_notifications table. I have had to leave some validations in this for now for our database consistency checks. Once the migration is complete we can delete the notifications table and this model.

@@ -15,7 +15,7 @@
.govuk-body.float-right
= pagy_stats(@pagy, type: "notification")

= render @notifications
= render partial: "notification", collection: @notifications, as: :notification
Copy link
Collaborator

Choose a reason for hiding this comment

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

Due to notifications now being called noticed_notifications we need to explicitly set this collection partial.

event = Noticed::Event.find(notification.event_id)

expect(notification).to have_attributes(expected_notification_attributes)
expect(event).to have_attributes(expected_event_attributes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We now have two models/tables rather than just one and they store different attributes

delegate :created_at, to: :record
param :vacancy, :publisher

notification_methods do
Copy link
Collaborator

Choose a reason for hiding this comment

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

As of v2 we need to wrap these methods in the notifications_method block to make them available on the notification, rather than the event of the same name

delegate :created_at, to: :record
param :vacancy, :job_application

notification_methods do
Copy link
Collaborator

Choose a reason for hiding this comment

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

As of v2 we need to wrap these methods in the notifications_method block to make them available on the notification, rather than the event of the same name

Copy link

github-actions bot commented Jun 19, 2024

Review app https://teaching-vacancies-review-pr-6889.test.teacherservices.cloud was successfully deleted

Copy link
Collaborator

@scruti scruti left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks for the very helpful annotations to review the PR 👏

@KyleMacPherson KyleMacPherson merged commit 556dab6 into main Jun 20, 2024
17 checks passed
@KyleMacPherson KyleMacPherson deleted the dependabot/bundler/noticed-2.3.2 branch June 20, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies deploy do not merge ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants