From 139c6651bfd624b87caac3b93d8e7535ac031c21 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 00:40:03 -0600 Subject: [PATCH 1/3] Update ApiController, fixes #1705 --- app/Http/Controllers/ApiController.php | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index d71da8ce8..38e888644 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -83,20 +83,24 @@ class ApiController extends BaseApiController { abort_if(!Auth::check(), 403); $this->validate($request, [ - 'q' => 'required|string' + 'q' => 'required|string|max:100' ]); $q = filter_var($request->input('q'), FILTER_SANITIZE_STRING); - $q = '%' . $q . '%'; - $places = Place::where('name', 'like', $q) - ->take(25) - ->get() - ->map(function($r) { - return [ - 'id' => $r->id, - 'name' => $r->name, - 'country' => $r->country, - 'url' => $r->url() - ]; + $hash = hash('sha256', $q); + $key = 'search:location:id:' . $hash; + $places = Cache::remember($key, now()->addMinutes(15), function() use($q) { + $q = '%' . $q . '%'; + return Place::where('name', 'like', $q) + ->take(80) + ->get() + ->map(function($r) { + return [ + 'id' => $r->id, + 'name' => $r->name, + 'country' => $r->country, + 'url' => $r->url() + ]; + }); }); return $places; } From fbef8977fd794da0fd42ac8c01372ea445f6a9c5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 00:47:25 -0600 Subject: [PATCH 2/3] Update Timeline.vue component, fix integer overflow bug in pagination --- resources/assets/js/components/Timeline.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index fdf8c1233..6de709a04 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -564,10 +564,7 @@ if(this.profile.is_admin == true) { this.modes.mod = true; } - $('.profile-card .loader').addClass('d-none'); - $('.profile-card .contents').removeClass('d-none'); - $('.profile-card .card-footer').removeClass('d-none'); - this.expRec(); + //this.expRec(); }).catch(err => { swal( 'Oops, something went wrong', @@ -602,8 +599,8 @@ this.feed.push(...data); let ids = data.map(status => status.id); this.ids = ids; - this.min_id = Math.max(...ids); - this.max_id = Math.min(...ids); + this.min_id = Math.max(...ids).toString(); + this.max_id = Math.min(...ids).toString(); this.loading = false; $('.timeline .pagination').removeClass('d-none'); // if(this.feed.length == 4) { @@ -626,6 +623,10 @@ $state.complete(); return; } + if(this.page > 40) { + this.loading = false; + $state.complete(); + } let apiUrl = false; switch(this.scope) { case 'home': @@ -655,8 +656,8 @@ self.ids.push(d.id); } }); - this.min_id = Math.max(...this.ids); - this.max_id = Math.min(...this.ids); + this.min_id = Math.max(...this.ids).toString(); + this.max_id = Math.min(...this.ids).toString(); this.page += 1; $state.loaded(); this.loading = false; From 871a91541ea1e28ddccb039b6e732f6f21447ff7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 00:49:11 -0600 Subject: [PATCH 3/3] Update compiled assets --- public/js/activity.js | Bin 7212 -> 7235 bytes public/js/timeline.js | Bin 71381 -> 71293 bytes public/mix-manifest.json | Bin 1655 -> 1655 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/activity.js b/public/js/activity.js index d6e4fbad067aba8e9108541026fdd885b380d547..7d764b10e2b1ed784aa02e980376098dc4e68f9e 100644 GIT binary patch delta 41 ucmZ2uaoA!*B%7d4bwOfLVs5cjbwRq7qCsu#=18_}jI1EG&SpLiIS~LjA`K$| delta 17 YcmX?XvBqLUB-`dJwrz}?)i`8D06%L5+W-In diff --git a/public/js/timeline.js b/public/js/timeline.js index fe8a0582e3a848c42cd67afffbcfb3e19e98b7e0..8bab66b0c9f1b73b2d6b66a18aaa8d4140559c66 100644 GIT binary patch delta 394 zcmcb*mgVmnmJM_HS=@7iA|^j%Q{P-H@I+wp29?;&VM>b_x%5i%gG-7s^U^gYe^*vP z=1QqJOm0-UW>k`qS*%x(n4W59VxXp`0p{l9C#C@P*eV+8l;|br=N9ComZWNEYFd{i z7AX`@u2WLlT&LR3$cr#tQzv!uFJ-yO|J2x#EZMBB{z{FdsKhLHv!vevD;_m9#S%TJ z;gfH6DDo(%sVOMJ1Z28oHj8yWRN^o&F*Qs}u`u2Ie|0?%vyWTFg0mZ~NU)?c9mZdN+!V9EgveV68uw|fd5RCxpQ_{39*2~k#)YMC?)dA_B w=wLZ{*)=)14U^AYi$ZYpuDc;PHP`hKoXyu)AUMf4q7j^9H{v#*zsY6`0OYWX$^ZZW delta 387 zcmeynhUMy7mJM_HS)4t6j3?J^mtx6JF0q*WVNK`ex%~WsJUS{GN_quF`DvLssgw8I zQD=v--``P}LzdJ{PAp1M&;yaWY5DmjsYR3j-I3tbDbY)fKsa!mP}lOHQNsG8W?mguFWrl#oSq~@iUWT>fuxFyLMA(^?UIhlE>js=+-lNFV3 zu$CnjDHKmOR8-pRtJ2Om`M#?9W`5dsCe5ze>vSg>sX5o&9N*sx4 zmMJO5sfnBatg7c>2CA9-kWF12tek;jZ96w#9AGtMAr~)C7{p6HaqT^A`9{U zfotJ#{gdUdM%WCIKHWK&}U6Vr`9(^w@e%}rCxO^gkVl9SR>lZ{Oc LEKMzyxN5lo7{d_W