projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug when no posts are in the db.
[akkoma]
/
lib
/
pleroma
/
user.ex
diff --git
a/lib/pleroma/user.ex
b/lib/pleroma/user.ex
index bf63a22b3f4075a16581bdfc7728654af8352ac5..5f1750035127b77ff9867af0bd145bf2a6a07daf 100644
(file)
--- a/
lib/pleroma/user.ex
+++ b/
lib/pleroma/user.ex
@@
-239,6
+239,15
@@
defmodule Pleroma.User do
{:ok, Repo.all(q)}
end
{:ok, Repo.all(q)}
end
+ def increase_note_count(%User{} = user) do
+ note_count = (user.info["note_count"] || 0) + 1
+ new_info = Map.put(user.info, "note_count", note_count)
+
+ cs = info_changeset(user, %{info: new_info})
+
+ Repo.update(cs)
+ end
+
def update_note_count(%User{} = user) do
note_count_query = from a in Object,
where: fragment("?->>'actor' = ? and ?->>'type' = 'Note'", a.data, ^user.ap_id, a.data),
def update_note_count(%User{} = user) do
note_count_query = from a in Object,
where: fragment("?->>'actor' = ? and ?->>'type' = 'Note'", a.data, ^user.ap_id, a.data),