mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update DiscoverController, add albums and video to discover trending api
This commit is contained in:
parent
96afc3e781
commit
b2fe219eec
1 changed files with 4 additions and 4 deletions
|
@ -170,26 +170,26 @@ class DiscoverController extends Controller
|
||||||
public function trendingApi(Request $request)
|
public function trendingApi(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'range' => 'nullable|string|in:daily,monthly,alltime'
|
'range' => 'nullable|string|in:daily,monthly'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$range = $request->filled('range') ?
|
$range = $request->filled('range') ?
|
||||||
$request->input('range') == 'alltime' ? '-1' :
|
$request->input('range') == 'alltime' ? '-1' :
|
||||||
($request->input('range') == 'daily' ? 1 : 31) : 1;
|
($request->input('range') == 'daily' ? 1 : 31) : 1;
|
||||||
|
|
||||||
$key = ':api:discover:trending:v2:range:' . $range;
|
$key = ':api:discover:trending:v2.1:range:' . $range;
|
||||||
$ttl = now()->addHours(2);
|
$ttl = now()->addHours(2);
|
||||||
$res = Cache::remember($key, $ttl, function() use($range) {
|
$res = Cache::remember($key, $ttl, function() use($range) {
|
||||||
if($range == '-1') {
|
if($range == '-1') {
|
||||||
$res = Status::whereScope('public')
|
$res = Status::whereScope('public')
|
||||||
->whereType('photo')
|
->whereIn('type', ['photo', 'photo:album', 'video'])
|
||||||
->whereIsNsfw(false)
|
->whereIsNsfw(false)
|
||||||
->orderBy('likes_count','desc')
|
->orderBy('likes_count','desc')
|
||||||
->take(12)
|
->take(12)
|
||||||
->get();
|
->get();
|
||||||
} else {
|
} else {
|
||||||
$res = Status::whereScope('public')
|
$res = Status::whereScope('public')
|
||||||
->whereType('photo')
|
->whereIn('type', ['photo', 'photo:album', 'video'])
|
||||||
->whereIsNsfw(false)
|
->whereIsNsfw(false)
|
||||||
->orderBy('likes_count','desc')
|
->orderBy('likes_count','desc')
|
||||||
->take(12)
|
->take(12)
|
||||||
|
|
Loading…
Reference in a new issue