mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-25 02:19:31 +00:00
Fix note count update.
This commit is contained in:
parent
6f90ceb2ed
commit
d5af41b577
|
@ -440,11 +440,13 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
note_count = Repo.one(note_count_query)
|
note_count = Repo.one(note_count_query)
|
||||||
|
|
||||||
new_info = Map.put(user.info, "note_count", note_count)
|
info_cng = User.Info.set_note_count(user.info, note_count)
|
||||||
|
|
||||||
cs = info_changeset(user, %{info: new_info})
|
cng =
|
||||||
|
change(user)
|
||||||
|
|> put_embed(:info, info_cng)
|
||||||
|
|
||||||
update_and_set_cache(cs)
|
update_and_set_cache(cng)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_follower_count(%User{} = user) do
|
def update_follower_count(%User{} = user) do
|
||||||
|
|
|
@ -27,6 +27,10 @@ defmodule Pleroma.User.Info do
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_note_count(info, number) do
|
def add_to_note_count(info, number) do
|
||||||
|
set_note_count(info, info.note_count + number)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_note_count(info, number) do
|
||||||
params = %{note_count: Enum.max([0, number])}
|
params = %{note_count: Enum.max([0, number])}
|
||||||
|
|
||||||
info
|
info
|
||||||
|
|
|
@ -311,11 +311,11 @@ defmodule Pleroma.UserTest do
|
||||||
|
|
||||||
user = User.get_by_ap_id(note.data["actor"])
|
user = User.get_by_ap_id(note.data["actor"])
|
||||||
|
|
||||||
assert user.info["note_count"] == nil
|
assert user.info.note_count == 0
|
||||||
|
|
||||||
{:ok, user} = User.update_note_count(user)
|
{:ok, user} = User.update_note_count(user)
|
||||||
|
|
||||||
assert user.info["note_count"] == 1
|
assert user.info.note_count == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it increases the info->note_count property" do
|
test "it increases the info->note_count property" do
|
||||||
|
|
Loading…
Reference in a new issue