|> Repo.exists?()
end
- |> where([r], r.state == "accept")
+ def following_query(%User{} = user) do
+ __MODULE__
+ |> join(:inner, [r], u in User, on: r.following_id == u.id)
+ |> where([r], r.follower_id == ^user.id)
++ |> where([r], r.state == ^:follow_accept)
+ end
+
def following(%User{} = user) do
following =
- __MODULE__
- |> join(:inner, [r], u in User, on: r.following_id == u.id)
- |> where([r], r.follower_id == ^user.id)
- |> where([r], r.state == ^:follow_accept)
+ following_query(user)
|> select([r, u], u.follower_address)
|> Repo.all()