Sort by updated_at

the updated_at column isn't indexed, so postgres won't take the wrong index.
This commit is contained in:
Roger Braun 2017-09-16 14:51:55 +02:00
parent f039c9c19a
commit 03952a2760
1 changed files with 2 additions and 1 deletions

View File

@ -212,7 +212,8 @@ def search(user, %{"q" => query} = params) do
where: fragment("?->>'type' = 'Create'", a.data), where: fragment("?->>'type' = 'Create'", a.data),
where: fragment("to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)", a.data, ^query), where: fragment("to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)", a.data, ^query),
limit: ^limit, limit: ^limit,
offset: ^offset offset: ^offset,
order_by: [desc: :updated_at] # this one isn't indexed so psql won't take the wrong index.
activities = Repo.all(q) activities = Repo.all(q)
activities_to_statuses(activities, %{for: user}) activities_to_statuses(activities, %{for: user})