app/workers/publishing_api_withdrawal_worker.rb
# `explanation` and `unpublished_at` come from the unpublishing object. Rather than
# performing a database query here to look up the `unpublishing` linked to the most
# recent edition, we pass it in directly because the `unpublishing` isn't always
# saved in the database yet when this worker runs.
`explanation` and `unpublished_at` come from the unpublishing object. Rather than
performing a database query here to look up the `unpublishing` linked to the most
recent edition, we pass it in directly because the `unpublishing` isn't always
saved in the database yet when this worker runs.
` explanation ` and ` unpublished_at ` come from the unpublishing object . Rather than performing a database query here to look up the ` unpublishing ` linked to the most recent edition we pass it in directly because the ` unpublishing ` isn ' t always saved in the database yet when this worker runs .
def find_unpublished_at(content_id, given_unpublished_at)
    if given_unpublished_at
      Time.zone.parse(given_unpublished_at.to_s)
    else
      Edition
        .joins(:document)
        .where(documents: { content_id: content_id })
        .where(state: "withdrawn")
        .pick(:updated_at)
    end
  end
def find_unpublished_at ( content_id , given_unpublished_at ) if given_unpublished_at Time . zone . parse ( given_unpublished_at . to_s ) else Edition . joins ( :document ) . where ( documents : { content_id : content_id } ) . where ( state : "withdrawn" ) . pick ( :updated_at ) end end
`explanation` and `unpublished_at` come from the unpublishing object.
` explanation ` and ` unpublished_at ` come from the unpublishing object .
# We call this job both directly and via Sidekiq. When called by Sidekiq, the date gets turned # into a string (because jobs must be JSON serialisable) and `Services.publishing_api.unpublish` # rejects it. # Temporary code to handle old workers that are still in the queue without an `unpublished_at`
content_id
given_unpublished_at