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

Change action terminology to sync/desync/skip #132

Merged
merged 1 commit into from
Dec 1, 2023
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: 5 additions & 5 deletions app/models/concerns/publishing_api/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ module Action
# behaviour of the existing search. This may change in the future.
PERMITTED_LOCALES = %w[en].freeze

def publish?
!unpublish? && !ignore?
def sync?
!desync? && !skip?
end

def unpublish?
def desync?
UNPUBLISH_DOCUMENT_TYPES.include?(document_type)
end

def ignore?
def skip?
on_ignorelist? || ignored_locale? || unaddressable? || withdrawn?
end

def ignore_reason
def action_reason
if on_ignorelist?
"document_type on ignorelist (#{document_type})"
elsif ignored_locale?
Expand Down
10 changes: 5 additions & 5 deletions app/models/publishing_api_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def initialize(
end

def synchronize
if publish?
log("put")
if sync?
log("sync")
put_service.call(content_id, metadata, content:, payload_version:)
elsif unpublish?
log("delete")
elsif desync?
log("desync (#{action_reason}))")
delete_service.call(content_id, payload_version:)
else
log("ignore and delete (#{ignore_reason})")
log("skip (#{action_reason})")
# Eagerly attempt to delete the document anyway in case it has been previously synchronised
# (for example, if the ignorelist has changed and it should now no longer be in search)
delete_service.call(content_id, payload_version:)
Expand Down
Loading