forked from mirror/pixelfed
Update DiscoverController
This commit is contained in:
parent
fd535fa464
commit
36e4f87386
1 changed files with 4 additions and 7 deletions
|
@ -28,16 +28,12 @@ class DiscoverController extends Controller
|
||||||
|
|
||||||
public function showTags(Request $request, $hashtag)
|
public function showTags(Request $request, $hashtag)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
|
||||||
'page' => 'nullable|integer|min:1|max:20',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$tag = Hashtag::whereSlug($hashtag)
|
$tag = Hashtag::whereSlug($hashtag)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
$page = $request->input('page') ?? 1;
|
$page = 1;
|
||||||
$key = 'discover:tag-'.$tag->id.':page-'.$page;
|
$key = 'discover:tag-'.$tag->id.':page-'.$page;
|
||||||
$keyMinutes = $page == 1 ? 15 : 5;
|
$keyMinutes = 15;
|
||||||
|
|
||||||
$posts = Cache::remember($key, now()->addMinutes($keyMinutes), function() use ($tag, $request) {
|
$posts = Cache::remember($key, now()->addMinutes($keyMinutes), function() use ($tag, $request) {
|
||||||
return $tag->posts()
|
return $tag->posts()
|
||||||
|
@ -48,7 +44,8 @@ class DiscoverController extends Controller
|
||||||
->whereIsNsfw(false)
|
->whereIsNsfw(false)
|
||||||
->whereVisibility('public')
|
->whereVisibility('public')
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->simplePaginate(24);
|
->take(24)
|
||||||
|
->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
if($posts->count() == 0) {
|
if($posts->count() == 0) {
|
||||||
|
|
Loading…
Reference in a new issue