Rename current_build sort to current_build_id

This a quick workaround for sorting by current_build. When the field
that we use to sort is the same as one of the associations name API V3
will try to join the association. So in this case it will try to join
:current_build, which fails. This needs a better solution, but I want to
get this working for now.
This commit is contained in:
Piotr Sarnacki 2016-06-06 14:39:40 +02:00
parent dbe0a75a22
commit 7317d6b265

View File

@ -4,7 +4,7 @@ module Travis::API::V3
sortable_by :id, :github_id, :owner_name, :name, active: sort_condition(:active), :'default_branch.last_build' => 'builds.started_at'
sortable_by :id, :github_id, :owner_name, :name, active: sort_condition(:active),
:'default_branch.last_build' => 'builds.started_at',
:current_build => "repositories.current_build_id %{order} NULLS LAST"
:current_build_id => "repositories.current_build_id %{order} NULLS LAST"
def for_member(user, **options)
all(user: user, **options).joins(:users).where(users: user_condition(user), invalidated_at: nil)