fix: improve performance of content search for large repos

This commit is contained in:
Ruben Fiszel
2024-07-06 01:06:50 +02:00
parent d50a1f4d94
commit 299e7cf5cf
@@ -103,6 +103,20 @@
flows: getCounts(filteredFlowItems.length),
scripts: getCounts(filteredScriptItems.length)
}
let showNbScripts = 10
let showNbApps = 10
let showNbResources = 10
let showNbFlows = 10
$: search && resetShows()
function resetShows() {
showNbScripts = 10
showNbApps = 10
showNbResources = 10
showNbFlows = 10
}
</script>
<SearchItems
@@ -280,7 +294,7 @@
{#if search.trim().length > 0}
<div class="flex flex-col gap-4">
{#if (searchKind == 'all' || searchKind == 'scripts') && filteredScriptItems?.length > 0}
{#each filteredScriptItems ?? [] as item}
{#each filteredScriptItems.slice(0, showNbScripts) ?? [] as item}
<div>
<div class="text-sm font-semibold"
><a href="/scripts/get/{item.path}">Script: {item.path}</a></div
@@ -308,9 +322,20 @@
</div>
</div>
{/each}
{#if filteredScriptItems.length > showNbScripts}
<a
href="#"
class="text-center font-semibold cursor-pointer pb-40"
on:click={() => {
showNbScripts += 30
}}
>
({showNbScripts} of {filteredScriptItems.length}) Show more scripts
</a>
{/if}
{/if}
{#if (searchKind == 'all' || searchKind == 'resources') && filteredResourceItems?.length > 0}
{#each filteredResourceItems ?? [] as item}
{#each filteredResourceItems.slice(0, showNbResources) ?? [] as item}
<div>
<div class="text-sm font-semibold">Resource: {item.path}</div>
<div class="flex gap-2 justify-between">
@@ -320,9 +345,20 @@
</div>
</div>
{/each}
{#if filteredResourceItems.length > showNbResources}
<a
href="#"
class="text-center font-semibold cursor-pointer pb-40"
on:click={() => {
showNbResources += 30
}}
>
({showNbResources} of {filteredResourceItems.length}) Show more resources
</a>
{/if}
{/if}
{#if (searchKind == 'all' || searchKind == 'flows') && filteredFlowItems?.length > 0}
{#each filteredFlowItems ?? [] as item}
{#each filteredFlowItems.slice(0, showNbFlows) ?? [] as item}
<div>
<div class="text-sm font-semibold"
><a href="/flows/get/{item.path}">Flow: {item.path}</a></div
@@ -347,10 +383,21 @@
</div>
</div>
</div>
{#if filteredFlowItems.length > showNbFlows}
<a
href="#"
class="text-center font-semibold cursor-pointer pb-40"
on:click={() => {
showNbScripts += 30
}}
>
({showNbFlows} of {filteredFlowItems.length}) Show more flows
</a>
{/if}
{/each}
{/if}
{#if (searchKind == 'all' || searchKind == 'apps') && filteredAppItems?.length > 0}
{#each filteredAppItems ?? [] as item}
{#each filteredAppItems.slice(0, showNbApps) ?? [] as item}
<div>
<div class="text-sm font-semibold"
><a href="/apps/get/{item.path}">App: {item.path}</a></div
@@ -362,6 +409,17 @@
</div>
</div>
{/each}
{#if filteredAppItems.length > showNbApps}
<a
href="#"
class="text-center font-semibold cursor-pointer pb-40"
on:click={() => {
showNbApps += 30
}}
>
({showNbApps} of {filteredAppItems.length}) Show more apps
</a>
{/if}
{/if}
</div>
{:else}