From 10b6058cc0738c88310baef473730b06354d2e2a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 29 Dec 2021 01:46:29 -0700 Subject: [PATCH 1/3] Update DiscoverController, add yearly option and increase limit from 15 to 30 posts --- app/Http/Controllers/DiscoverController.php | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 7b0a6d731..659b06707 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -117,18 +117,22 @@ class DiscoverController extends Controller abort_if(config('instance.discover.public') == false && !Auth::check(), 403); $this->validate($request, [ - 'range' => 'nullable|string|in:daily,monthly' + 'range' => 'nullable|string|in:daily,monthly,yearly', ]); - $range = $request->input('range') == 'monthly' ? 31 : 1; + $range = $request->input('range'); + $days = $range == 'monthly' ? 31 : ($range == 'daily' ? 1 : 365); + $ttls = [ + 1 => 1500, + 31 => 14400, + 365 => 86400 + ]; + $key = ':api:discover:trending:v2.12:range:' . $days; - $key = ':api:discover:trending:v2.8:range:' . $range; - $ttl = now()->addMinutes(15); - - $ids = Cache::remember($key, $ttl, function() use($range) { - $days = $range == 1 ? 2 : 31; + $ids = Cache::remember($key, $ttls[$days], function() use($days) { $min_id = SnowflakeService::byDate(now()->subDays($days)); - return Status::select( + return DB::table('statuses') + ->select( 'id', 'scope', 'type', @@ -146,7 +150,7 @@ class DiscoverController extends Controller ]) ->whereIsNsfw(false) ->orderBy('likes_count','desc') - ->take(15) + ->take(30) ->pluck('id'); }); @@ -155,7 +159,10 @@ class DiscoverController extends Controller $res = $ids->map(function($s) { return StatusService::get($s); })->filter(function($s) use($filtered) { - return $s && !in_array($s['account']['id'], $filtered); + return + $s && + !in_array($s['account']['id'], $filtered) && + isset($s['account']); })->values(); return response()->json($res); From 50e845d606d85be2b035c322f0336f7b8668de4b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 29 Dec 2021 01:47:15 -0700 Subject: [PATCH 2/3] Update compiled assets --- public/js/spa.js | Bin 1700796 -> 1701041 bytes public/mix-manifest.json | Bin 1983 -> 1983 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/spa.js b/public/js/spa.js index 9ca951b4b443806d3f1499572c849fa5aaa36067..4a5e0690faa8601a19a1980a35824a7383b8370a 100644 GIT binary patch delta 1032 zcmZvbZ)g*D7{|F@@~g4Q<(JE!TQupe=b+7&#FnN>mr+*VSd`-WqAwJ6^|a?Tm|mLe zsVx}SR=cowf+Wv|jwu*L477v6kFkOOUTlND=)fXcw3cZ*K|?@%RoMI`ZLtMke7Jj_ z@9%k@?>*e__ht3xm+IJg=9ilNMN=fPQvzlO8-rWd1m4ot9*woOM&-jW+hlX)3pG|) zx+d5+v2#F8@i(PCp0yr%bKc);iHBYA4r{2^thHXnkr$azoO^?XqaNWw&Ta-Ho5JK zLt19N2^=m7AH&LPp}RVx5+2Cfi-=N7*+Q{Uwo>Ydy=c8U$F}cQR@d4bWKq^XVWV&q zJMmB8`!W}-nu$yOaw0h@!T520J6ZV$N0}|gKw>ydRdAel`=OI_N%EC+ z=7qqnan!)*aCQPsH&i>V_HSDA7RY2W!GlJ)?^Ki2n}TxM<%a1wFNVYfvaZ$9N9-ID zxAs!+;$TWM2B77fb33HYGRP*4DzZ*LvZKQYua5b2)0j1R)0|45N?wAN4CjTOLBAa<%G@596U-hccX<#z z`4{gYz8tP&;K~)Qj%eSac?N!6;+-&-Lk<%79{*Vb-51aw@Yid65PEXxCM?{Jc^Qgh9 zM~{w5flM&HKi%^FCnG;R73widwTmrhwwYq|W`pAs_B)fVDzR!|cD^J~J|goa@1p4) DwB~Gb delta 1040 zcmZvbZ)h8J7{^I+x#mxk{O*#wG#TBl+30d3S2MG={-p+yxo*@>#0g#P()1c{TrO$; z%*HmZ!?EBCWjNL^LmeGD>Yz0ph=)#x3PTVv*^9jxgGt#7r(<;Sg(y<%rE{Bt{P?_h zp6B~KKc46L{m%cK`r@b5%u&-P=9d;KTGeb|F`#sl+;H~@>4K!~ z2$ds4S~!H@H@;5H1$hd!3!bny*7O&;vYBjAP2}RqWTuG5XS^Z#*8MPkn0G&96|yBM zipI1nfasHKAgn6+f{|6|8d1al&D09{uDq%w<#03-6LGnZkxmYB0etm6XT`urZW zyIIXWt$xaGLv0sN2M2SRaYdEGidZhMmw6y!PI~$=x5euKX(t?>>gPqw?D9FRWl@Yo z@!<$xfaj{$im#Ug!Py&(6F=_fIc!>CY}*F!u18qkk1^$tIBcBqaHL~aEZM;e~pZSUH(?Ke&Jg;EyJpHEb zJjdfNOVf;BGWX)df|<45D~iPhbJTgy8WyIoH{uFHh*A^=Zuyy(e=f&zuW17wT{ORK zzc0r5CnydxADdYm7F{$}7tQkjM2r9OT|Vs(L8zMd=x65rS9)8Yt0j>rKcK`qY delta 33 ocmdnbzn_1@Y&H=y6O*LmWRnyNBZD+ci^OCD^E9)~>)8Yt0k^yg5dZ)H From 69133660635b12622df36b941f8ddbb87b3f57c1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 29 Dec 2021 01:47:31 -0700 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adb754bf5..220111d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Metro 2.0 UI - Added UI Settings modal and fixed height media previews setting ([f2467e71](https://github.com/pixelfed/pixelfed/commit/f2467e71)) +- Set max-width of 1440px for larger screens ([af68872a](https://github.com/pixelfed/pixelfed/commit/af68872a)) ### Added - Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387)) @@ -68,7 +69,8 @@ - Updated Webfinger, fixes #3050. ([ff7ee3bd](https://github.com/pixelfed/pixelfed/commit/ff7ee3bd)) - Updated status api, autolink caption before returning response. ([b00a453b](https://github.com/pixelfed/pixelfed/commit/b00a453b)) - Updated Timeline, add new ui promo in timelines that can be hidden using localstorage. ([e13959ae](https://github.com/pixelfed/pixelfed/commit/e13959ae)) -- Update FederationController, increase webfinger cache ttl from 12 hours to 14 days. ([745c3580](https://github.com/pixelfed/pixelfed/commit/745c3580)) +- Updated FederationController, increase webfinger cache ttl from 12 hours to 14 days. ([745c3580](https://github.com/pixelfed/pixelfed/commit/745c3580)) +- Updated DiscoverController, add yearly option and increase limit from 15 to 30 posts. ([10b6058c](https://github.com/pixelfed/pixelfed/commit/10b6058c)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)