Merge branch 'investigate-public-timeline-cached' into timeline-improvements

pull/6586/head
Your Name 3 months ago
commit 49211c129e

@ -2863,51 +2863,18 @@ class ApiV1Controller extends Controller
->toArray();
}
} else {
if (config('instance.timeline.local.cached')) {
Cache::remember('api:v1:timelines:public:cache_check', 10368000, function () {
if (PublicTimelineService::count() == 0) {
PublicTimelineService::warmCache(true, 400);
}
});
if ($max) {
$feed = PublicTimelineService::getRankedMaxId($max, $limit + 5);
} elseif ($min) {
$feed = PublicTimelineService::getRankedMinId($min, $limit + 5);
} else {
$feed = PublicTimelineService::get(0, $limit + 5);
Cache::remember('api:v1:timelines:public:cache_check', 10368000, function () {
if (PublicTimelineService::count() == 0) {
PublicTimelineService::warmCache(true, 400);
}
} else {
$feed = Status::select(
'id',
'uri',
'type',
'scope',
'local',
'created_at',
'profile_id',
'in_reply_to_id',
'reblog_of_id'
)
->when($minOrMax, function ($q, $minOrMax) use ($min, $max) {
$dir = $min ? '>' : '<';
$id = $min ?? $max;
});
return $q->where('id', $dir, $id);
})
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->when($hideNsfw, function ($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereLocal(true)
->whereScope('public')
->where('id', '>', $amin)
->orderByDesc('id')
->limit(($limit * 2))
->pluck('id')
->values()
->toArray();
if ($max) {
$feed = PublicTimelineService::getRankedMaxId($max, $limit + 5);
} elseif ($min) {
$feed = PublicTimelineService::getRankedMinId($min, $limit + 5);
} else {
$feed = PublicTimelineService::get(0, $limit + 5);
}
}

@ -30,7 +30,6 @@ return [
],
'local' => [
'cached' => env('INSTANCE_PUBLIC_TIMELINE_CACHED', false),
'is_public' => env('INSTANCE_PUBLIC_LOCAL_TIMELINE', false),
],

Loading…
Cancel
Save