add tests

This commit is contained in:
Maksim Pechnikov 2019-10-23 22:48:04 +03:00
commit d3fb9e02cc
4 changed files with 23 additions and 7 deletions

View file

@ -58,7 +58,8 @@ defmodule Pleroma.Marker do
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)
last_read_id:
type(fragment("MAX( CASE WHEN seen = true THEN id ELSE null END )"), :string)
}
)
@ -77,11 +78,7 @@ defmodule Pleroma.Marker do
)
end
def set_unread_count(%User{} = user, timeline) do
Multi.new()
|> multi_set_unread_count(user, timeline)
|> Repo.transaction()
end
def multi_set_unread_count(multi, _, _), do: multi
defp get_marker(user, timeline) do
case Repo.find_resource(get_query(user, timeline)) do