Fix bug when no posts are in the db.

This commit is contained in:
Roger Braun 2017-11-05 12:05:25 +01:00
parent 8a1a7191fd
commit 046bee34d3
2 changed files with 3 additions and 1 deletions

View file

@ -157,7 +157,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
# Only search through last 100_000 activities by default # Only search through last 100_000 activities by default
defp restrict_recent(query, _) do defp restrict_recent(query, _) do
since = Repo.aggregate(Activity, :max, :id) - 100_000 since = (Repo.aggregate(Activity, :max, :id) || 0) - 100_000
from activity in query, from activity in query,
where: activity.id > ^since where: activity.id > ^since

View file

@ -82,6 +82,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
describe "public fetch activities" do describe "public fetch activities" do
test "retrieves public activities" do test "retrieves public activities" do
activities = ActivityPub.fetch_public_activities
%{public: public} = ActivityBuilder.public_and_non_public %{public: public} = ActivityBuilder.public_and_non_public
activities = ActivityPub.fetch_public_activities activities = ActivityPub.fetch_public_activities