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

CRM457-2076: Go back to telling app store about new versions immediately #816

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ class Event < ApplicationRecord
'Event::DeleteAdjustments',
].freeze

# These are events that we know can exist in our local database for a significant
# period without existing in the app store database. All other events are either
# synced to the app store immediately after creation via a `.notify` call, or
# only created as part of a larger action that is followed immediately by a
# call to `NotifyAppStore` which syncs all events anyway.
# It is important to keep track of these so that we can infer what the app
# store thinks the latest event date is (so that the 'last updated' date
# we display in the UI is consistent with the value the app store uses
# for sorting and filtering search results)
LOCAL_EVENTS = [
'Event::DraftDecision',
'Event::NewVersion',
patrick-laa marked this conversation as resolved.
Show resolved Hide resolved
'Event::Edit',
'Event::Note',
'Event::UndoEdit',
Expand Down
4 changes: 3 additions & 1 deletion app/models/event/new_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class Event
class NewVersion < Event
def self.build(submission:)
create(submission: submission, submission_version: submission.current_version)
# We notify the app store immediately of a new version, because its analytics mechanism
# depends on having new version events available.
create(submission: submission, submission_version: submission.current_version).tap(&:notify)
end

def body
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class BackFillNewVersionNotifications < ActiveRecord::Migration[7.1]
def change
# Unassessed submissions haven't been pushing their new version events to the app
# store recently. Once they are assessed or sent back those events get synced,
# so it's only the ones that are still awaiting assessment that could be out
# of sync
Submission.where(state: %w[submitted provider_updated]).find_each do |submission|
last_new_version_event = submission.events.where(event_type: 'Event::NewVersion').order(:created_at).last
last_new_version_event&.notify
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.