)
end
- def update_follow_request_count(%User{} = user) do
- subquery =
+ def get_follow_requests(%User{} = user) do
- q = get_follow_requests_query(user)
- reqs = Repo.all(q)
-
+ users =
- Enum.map(reqs, fn req -> req.actor end)
- |> Enum.uniq()
- |> Enum.map(fn ap_id -> get_by_ap_id(ap_id) end)
- |> Enum.filter(fn u -> !is_nil(u) end)
- |> Enum.filter(fn u -> !following?(u, user) end)
+ user
+ |> User.get_follow_requests_query()
- |> select([a], %{count: count(a.id)})
++ |> join(:inner, [a], u in User, a.actor == u.ap_id)
++ |> where([a, u], not fragment("? @> ?", u.following, ^[user.follower_address]))
++ |> group_by([a, u], u.id)
++ |> select([a, u], u)
++ |> Repo.all()
+
+ {:ok, users}
+ end
+ def increase_note_count(%User{} = user) do
User
|> where(id: ^user.id)
- |> join(:inner, [u], s in subquery(subquery))
- |> update([u, s],
+ |> update([u],
set: [
info:
fragment(