Merge branch '37231-mysql2-error-unknown-column-award_emoji-count-on-master' into 'master'

Resolve "Mysql2::Error: Unknown column 'award_emoji.count' on master"

Closes #37231

See merge request !13926
This commit is contained in:
Grzegorz Bizon 2017-08-30 15:15:23 +00:00
commit f35d7d7f6e
4 changed files with 7 additions and 5 deletions

View file

@ -55,7 +55,7 @@ class AutocompleteController < ApplicationController
.limit(AWARD_EMOJI_MAX)
.where(user: current_user)
.group(:name)
.order(count: :desc, name: :asc)
.order('count_all DESC, name ASC')
.count
# Transform from hash to array to guarantee json order

View file

@ -130,7 +130,7 @@ module API
commit = user_project.repository.commit(branch.dereferenced_target)
destroy_conditionally!(commit, last_update_field: :authored_date) do
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = DeleteBranchService.new(user_project, current_user)
.execute(params[:branch])

View file

@ -19,8 +19,10 @@ module API
end
end
def destroy_conditionally!(resource, last_update_field: :updated_at)
check_unmodified_since!(resource.public_send(last_update_field))
def destroy_conditionally!(resource, last_updated: nil)
last_updated ||= resource.updated_at
check_unmodified_since!(last_updated)
status 204
if block_given?

View file

@ -70,7 +70,7 @@ module API
commit = user_project.repository.commit(tag.dereferenced_target)
destroy_conditionally!(commit, last_update_field: :authored_date) do
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = ::Tags::DestroyService.new(user_project, current_user)
.execute(params[:tag_name])