Skip to content

Commit

Permalink
Don't try to publish unsuitable editions
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiecobbett committed Mar 27, 2013
1 parent 21db5f3 commit 98dc819
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/batch_publish.rb
Expand Up @@ -5,7 +5,8 @@ def initialize(edition_identifiers, email)
end

def call
editions = @edition_identifiers.map do |identifier|
editions = []
@edition_identifiers.each do |identifier|
edition = Edition.where(
slug: identifier.fetch(:slug),
version_number: identifier.fetch(:edition)
Expand All @@ -14,12 +15,11 @@ def call
Rails.logger.error "Edition couldn't be found for #{identifier}"
elsif ["ready", "published"].exclude?(edition.state)
Rails.logger.error "Edition #{identifier} isn't 'published' or 'ready'. It's #{edition.state}"
else
editions << edition
end
edition
end

editions = editions.compact

editions.each do |edition|
published = user.progress(edition, { request_type: "publish", comment: "" })
if published
Expand Down

0 comments on commit 98dc819

Please sign in to comment.