projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9af5600
)
Use more efficient query to fetch likes.
author
Roger Braun
<rbraun@Bobble.local>
Tue, 24 Oct 2017 12:39:01 +0000
(14:39 +0200)
committer
Roger Braun
<rbraun@Bobble.local>
Tue, 24 Oct 2017 12:39:01 +0000
(14:39 +0200)
lib/pleroma/web/activity_pub/utils.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/activity_pub/utils.ex
b/lib/pleroma/web/activity_pub/utils.ex
index 4b8e6b690023ada758d551565820fd4174b21701..4e3a7e2bd6b0ffbadfda825aedefc1711cbfcc67 100644
(file)
--- a/
lib/pleroma/web/activity_pub/utils.ex
+++ b/
lib/pleroma/web/activity_pub/utils.ex
@@
-90,7
+90,11
@@
defmodule Pleroma.Web.ActivityPub.Utils do
"""
def get_existing_like(actor, %{data: %{"id" => id}} = object) do
query = from activity in Activity,
- where: fragment("? @> ?", activity.data, ^%{actor: actor, object: id, type: "Like"})
+ where: fragment("(?)->>'actor' = ?", activity.data, ^actor),
+ # this is to use the index
+ where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^id),
+ where: fragment("(?)->>'type' = 'Like'", activity.data)
+
Repo.one(query)
end