Skip to content

Commit

Permalink
Minor code formatting improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Dec 23, 2016
1 parent 4f178c3 commit 76134ea
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
6 changes: 2 additions & 4 deletions app/commands/v2/discard_draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ def increment_live_lock_version

def draft
@draft ||= ContentItem.joins(:document).find_by(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: "draft",
)
end

def live
@live ||= ContentItem.joins(:document).find_by(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: %w(published unpublished),
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/commands/v2/patch_link_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def schema_validator

def schema_name
@schema_name ||= Queries::GetLatest.(
ContentItem.where('documents.content_id': payload[:content_id])
ContentItem.where(documents: { content_id: content_id })
).pluck(:schema_name).first
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/commands/v2/post_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def action_type

def find_content_item
content_item = ContentItem.joins(:document).find_by(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: draft? ? %w(draft) : %w(published unpublished),
)

Expand Down
4 changes: 2 additions & 2 deletions app/commands/v2/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def find_draft_content_item

def already_published?
ContentItem.joins(:document)
.exists?("documents.content_id": content_id,
"documents.locale": locale, state: "published")
.exists?(documents: { content_id: content_id, locale: locale },
state: "published")
end

def pessimistic_document_scope
Expand Down
3 changes: 1 addition & 2 deletions app/commands/v2/put_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ def pessimistic_document_scope
def previously_published_item
@previously_published_item ||=
ContentItem.joins(:document).find_by(
"documents.content_id": content_id,
documents: { content_id: content_id, locale: locale },
state: %w(published unpublished),
"documents.locale": locale,
) || ITEM_NOT_FOUND
end

Expand Down
9 changes: 3 additions & 6 deletions app/commands/v2/unpublish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ def find_unpublishable_content_item
end

content_item = ContentItem.joins(:document).where(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: allowed_states
).lock.first

Expand All @@ -140,16 +139,14 @@ def previous_item

def previous_items
@previous_items ||= ContentItem.joins(:document).where(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: %w(published unpublished),
)
end

def draft_exists?
ContentItem.joins(:document).where(
'documents.content_id': content_id,
'documents.locale': locale,
documents: { content_id: content_id, locale: locale },
state: "draft",
).exists?
end
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/change_history_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def change_notes_for_content_item

def content_item_ids
ContentItem.joins(:document)
.where('documents.content_id': content_item.content_id)
.where("user_facing_version <= ?", version_number)
.pluck(:id)
.where("documents.content_id": content_item.content_id)
.where("user_facing_version <= ?", version_number)
.pluck(:id)
end

def version_number
Expand Down

0 comments on commit 76134ea

Please sign in to comment.