mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 08:43:17 +00:00
commit
ff1a12cdd7
3 changed files with 16 additions and 18 deletions
|
@ -2446,7 +2446,7 @@ class ApiV1Controller extends Controller
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
$filters = UserFilterService::filters($pid);
|
$filters = UserFilterService::filters($pid);
|
||||||
$forYou = DiscoverService::getForYou();
|
$forYou = DiscoverService::getForYou();
|
||||||
$posts = $forYou->random(50)->map(function($post) {
|
$posts = $forYou->take(50)->map(function($post) {
|
||||||
return StatusService::get($post);
|
return StatusService::get($post);
|
||||||
})
|
})
|
||||||
->filter(function($post) use($filters) {
|
->filter(function($post) use($filters) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ class InternalApiController extends Controller
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
$filters = UserFilterService::filters($pid);
|
$filters = UserFilterService::filters($pid);
|
||||||
$forYou = DiscoverService::getForYou();
|
$forYou = DiscoverService::getForYou();
|
||||||
$posts = $forYou->random(50)->map(function($post) {
|
$posts = $forYou->take(50)->map(function($post) {
|
||||||
return StatusService::get($post);
|
return StatusService::get($post);
|
||||||
})
|
})
|
||||||
->filter(function($post) use($filters) {
|
->filter(function($post) use($filters) {
|
||||||
|
|
|
@ -3,28 +3,26 @@
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use App\Status;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class DiscoverService
|
class DiscoverService
|
||||||
{
|
{
|
||||||
public static function getDailyIdPool()
|
public static function getDailyIdPool()
|
||||||
{
|
{
|
||||||
$min_id = SnowflakeService::byDate(now()->subMonths(3));
|
$min_id = SnowflakeService::byDate(now()->subMonths(3));
|
||||||
return Status::select(
|
$sqld = config('database.default') == 'mysql';
|
||||||
'id',
|
return DB::table('statuses')
|
||||||
'is_nsfw',
|
->whereNull('uri')
|
||||||
'profile_id',
|
->whereType('photo')
|
||||||
'type',
|
->whereIsNsfw(false)
|
||||||
'uri',
|
->whereVisibility('public')
|
||||||
)
|
->when($sqld, function($q, $sqld) {
|
||||||
->whereNull('uri')
|
return $q->groupBy('profile_id');
|
||||||
->whereType('photo')
|
})
|
||||||
->whereIsNsfw(false)
|
->where('id', '>', $min_id)
|
||||||
->whereVisibility('public')
|
->inRandomOrder()
|
||||||
->where('id', '>', $min_id)
|
->take(300)
|
||||||
->inRandomOrder()
|
->pluck('id');
|
||||||
->take(300)
|
|
||||||
->pluck('id');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getForYou()
|
public static function getForYou()
|
||||||
|
|
Loading…
Reference in a new issue