From 4dcbb64f19723334a9ef66b4ce71856d30e32796 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 31 Oct 2017 16:37:11 +0100 Subject: Avoid potentially slow count queries for user note count. For a variety of reasons, posgresql won't use the available actor, type index to do an index only scan. We now just increase the user note count, which will lead to slightly wrong counts in some cases, but it's better than the potentially very slow count query. --- test/user_test.exs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/user_test.exs b/test/user_test.exs index 097d7d98e..ae9a48e74 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -246,6 +246,21 @@ defmodule Pleroma.UserTest do assert user.info["note_count"] == 1 end + test "it increases the info->note_count property" do + note = insert(:note) + user = User.get_by_ap_id(note.data["actor"]) + + assert user.info["note_count"] == nil + + {:ok, user} = User.increase_note_count(user) + + assert user.info["note_count"] == 1 + + {:ok, user} = User.increase_note_count(user) + + assert user.info["note_count"] == 2 + end + test "it sets the info->follower_count property" do user = insert(:user) follower = insert(:user) -- cgit v1.2.3