fix `order by` for fetch_favorites
This commit is contained in:
parent
0937895182
commit
5cee51fac5
|
@ -78,7 +78,8 @@ defp cast_params(params) do
|
||||||
since_id: :string,
|
since_id: :string,
|
||||||
max_id: :string,
|
max_id: :string,
|
||||||
offset: :integer,
|
offset: :integer,
|
||||||
limit: :integer
|
limit: :integer,
|
||||||
|
skip_order: :boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
params =
|
params =
|
||||||
|
@ -103,6 +104,8 @@ defp restrict(query, :max_id, %{max_id: max_id}, table_binding) do
|
||||||
where(query, [{q, table_position(query, table_binding)}], q.id < ^max_id)
|
where(query, [{q, table_position(query, table_binding)}], q.id < ^max_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp restrict(query, :order, %{skip_order: true}, _), do: query
|
||||||
|
|
||||||
defp restrict(query, :order, %{min_id: _}, table_binding) do
|
defp restrict(query, :order, %{min_id: _}, table_binding) do
|
||||||
order_by(
|
order_by(
|
||||||
query,
|
query,
|
||||||
|
|
|
@ -1067,7 +1067,11 @@ def fetch_favourites(user, params \\ %{}, pagination \\ :keyset) do
|
||||||
|> Object.with_joined_activity()
|
|> Object.with_joined_activity()
|
||||||
|> select([_like, object, activity], %{activity | object: object})
|
|> select([_like, object, activity], %{activity | object: object})
|
||||||
|> order_by([like, _, _], desc: like.updated_at)
|
|> order_by([like, _, _], desc: like.updated_at)
|
||||||
|> Pagination.fetch_paginated(params, pagination, :object_activity)
|
|> Pagination.fetch_paginated(
|
||||||
|
Map.merge(params, %{"skip_order" => true}),
|
||||||
|
pagination,
|
||||||
|
:object_activity
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_update_cc(activities, list_memberships, %User{ap_id: user_ap_id})
|
defp maybe_update_cc(activities, list_memberships, %User{ap_id: user_ap_id})
|
||||||
|
|
Loading…
Reference in New Issue