Skip to content

Commit

Permalink
Merge pull request #132 from alphagov/sync-naming
Browse files Browse the repository at this point in the history
Change action terminology to sync/desync/skip
  • Loading branch information
csutter authored Dec 1, 2023
2 parents 994fed7 + 29499f5 commit 8237eff
Show file tree
Hide file tree
Showing 5 changed files with 1,323 additions and 33 deletions.
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

0 comments on commit 8237eff

Please sign in to comment.