Fix rejecting duplicated bites
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
ad0ebe666c
commit
e79dcd2bfe
1 changed files with 10 additions and 0 deletions
|
@ -971,6 +971,7 @@ def fetch_latest_bite(
|
|||
|> maybe_exclude_activity_id(exclude_activity)
|
||||
|> Activity.Queries.by_object_id(bitten_ap_id)
|
||||
|> order_by([activity], fragment("? desc nulls last", activity.id))
|
||||
|> exclude_rejected()
|
||||
|> limit(1)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
@ -981,4 +982,13 @@ defp maybe_exclude_activity_id(query, %Activity{id: activity_id}) do
|
|||
query
|
||||
|> where([a], a.id != ^activity_id)
|
||||
end
|
||||
|
||||
defp exclude_rejected(query) do
|
||||
rejected_activities = "Reject"
|
||||
|> Activity.Queries.by_type()
|
||||
|> select([a], fragment("?->>'object'", a.data))
|
||||
|
||||
query
|
||||
|> where([a], fragment("?->>'id'", a.data) not in subquery(rejected_activities))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue