defmodule Pleroma.Notification do
use Ecto.Schema
- alias Pleroma.{User, Activity, Notification, Repo}
+
+ alias Pleroma.User
+ alias Pleroma.Activity
+ alias Pleroma.Notification
+ alias Pleroma.Repo
alias Pleroma.Web.CommonAPI.Utils
+
import Ecto.Query
schema "notifications" do
n in Notification,
where: n.user_id == ^user.id,
order_by: [desc: n.id],
- preload: [:activity],
+ join: activity in assoc(n, :activity),
+ preload: [activity: activity],
limit: 20
)
from(
n in Notification,
where: n.id == ^id,
- preload: [:activity]
+ join: activity in assoc(n, :activity),
+ preload: [activity: activity]
)
notification = Repo.one(query)