I’ve been using Ecto for a small project and everything has been falling into place until I need to use window API.
The issue is that I want to filter a particular item out of windows result.
the query is like this
query = from u in User, as: :user, windows: [
w: [partition_by: u.category, order_by: [desc: u.activity_count]]
], select: {rank() |> over(:w), t.name, t.activity_count}
I only want to get a particular user with an id of 5 and his/her current rank based on activity count.
This is what I’m currently doing.
id = 5
from user in query, where: user.id == ^id
I understand that ecto is merging a query alike this as if written together in a single query which won’t
work.
no matter what I request, I will always get the rank as 1
{1, "John Bellman", 39}
Thank you.