From fc368bcd1a5009ef719f2bc9a8ab7be979a4e8da Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Tue, 31 Oct 2023 11:01:22 +0100 Subject: [PATCH] improve search performance in contribution member search --- app/Member/MemberResource.php | 4 ++++ resources/js/views/contribution/VIndex.vue | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 6493fb5f..629c0211 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -119,6 +119,10 @@ class MemberResource extends JsonResource */ public static function meta(): array { + if (request()->header('X-Meta') === 'false') { + return []; + } + if (request()->header('X-Inertia-Partial-Data', '') !== '' && !str_contains(request()->header('X-Inertia-Partial-Data', ''), 'meta')) { return []; } diff --git a/resources/js/views/contribution/VIndex.vue b/resources/js/views/contribution/VIndex.vue index 8e22e729..146be927 100644 --- a/resources/js/views/contribution/VIndex.vue +++ b/resources/js/views/contribution/VIndex.vue @@ -25,7 +25,7 @@ + " v-text="compiler.title"> @@ -66,13 +66,17 @@ export default { this.search.s = event; debounce(async () => { - var response = await this.axios.post('/api/member/search', { - filter: { - search: event, - hasBirthday: true, - hasFullAddress: true, + var response = await this.axios.post( + '/api/member/search', + { + filter: { + search: event, + hasBirthday: true, + hasFullAddress: true, + }, }, - }); + { headers: { 'X-Meta': 'false' } } + ); this.search.results = response.data.data; }, 300)();