|
@@ -3,28 +3,26 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
-use App\Status;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class DiscoverService
|
|
|
{
|
|
|
public static function getDailyIdPool()
|
|
|
{
|
|
|
$min_id = SnowflakeService::byDate(now()->subMonths(3));
|
|
|
- return Status::select(
|
|
|
- 'id',
|
|
|
- 'is_nsfw',
|
|
|
- 'profile_id',
|
|
|
- 'type',
|
|
|
- 'uri',
|
|
|
- )
|
|
|
- ->whereNull('uri')
|
|
|
- ->whereType('photo')
|
|
|
- ->whereIsNsfw(false)
|
|
|
- ->whereVisibility('public')
|
|
|
- ->where('id', '>', $min_id)
|
|
|
- ->inRandomOrder()
|
|
|
- ->take(300)
|
|
|
- ->pluck('id');
|
|
|
+ $sqld = config('database.default') == 'mysql';
|
|
|
+ return DB::table('statuses')
|
|
|
+ ->whereNull('uri')
|
|
|
+ ->whereType('photo')
|
|
|
+ ->whereIsNsfw(false)
|
|
|
+ ->whereVisibility('public')
|
|
|
+ ->when($sqld, function($q, $sqld) {
|
|
|
+ return $q->groupBy('profile_id');
|
|
|
+ })
|
|
|
+ ->where('id', '>', $min_id)
|
|
|
+ ->inRandomOrder()
|
|
|
+ ->take(300)
|
|
|
+ ->pluck('id');
|
|
|
}
|
|
|
|
|
|
public static function getForYou()
|