From b35ff8f75592062dc8b6a4cc3a9ac0518b94b16a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 23 Oct 2017 18:36:53 +0200 Subject: [PATCH] Use index in basic activity query. --- lib/pleroma/activity.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index d7e31b6b4..f43b32b56 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -38,7 +38,7 @@ def all_by_object_ap_id(ap_id) do def get_create_activity_by_object_ap_id(ap_id) do Repo.one(from activity in Activity, - where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id)) - and fragment("(?)->>'type' = 'Create'", activity.data)) + where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)), + where: fragment("(?)->>'type' = 'Create'", activity.data)) end end