From 493c5ca0ce1a3c8531df5dcf088bbde6495e8f26 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 19 Dec 2021 00:43:09 -0700 Subject: [PATCH] Add DiscoverService --- app/Services/DiscoverService.php | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/Services/DiscoverService.php diff --git a/app/Services/DiscoverService.php b/app/Services/DiscoverService.php new file mode 100644 index 000000000..6f4acfc01 --- /dev/null +++ b/app/Services/DiscoverService.php @@ -0,0 +1,36 @@ +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'); + } + + public static function getForYou() + { + return Cache::remember('pf:services:discover:for-you', 21600, function() { + return self::getDailyIdPool(); + }); + } +}