clean sql query

This commit is contained in:
Maksim Pechnikov 2019-11-11 17:06:41 +03:00
parent ff6c727739
commit ddbfc995ac
2 changed files with 1 additions and 3 deletions

View File

@ -56,7 +56,7 @@ def multi_set_unread_count(multi, %User{} = user, "notifications") do
|> Multi.insert(
:marker,
fn %{counters: attrs} ->
Marker
%Marker{timeline: "notifications", user_id: user.id}
|> struct(attrs)
|> Ecto.Changeset.change()
end,

View File

@ -41,8 +41,6 @@ def notifications_info_query(user) do
from(q in Pleroma.Notification,
where: q.user_id == ^user.id,
select: %{
timeline: "notifications",
user_id: type(^user.id, :string),
unread_count: fragment("SUM( CASE WHEN seen = false THEN 1 ELSE 0 END )"),
last_read_id:
type(fragment("MAX( CASE WHEN seen = true THEN id ELSE null END )"), :string)