-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ts/redis-query-caching'
- Loading branch information
Showing
43 changed files
with
810 additions
and
186 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
#!/bin/bash | ||
|
||
ENV_LOCAL_FILE_PATH="../.env.local" | ||
ENV_LOCAL_FILE_PATH_DOCKER="../../.env.local" | ||
|
||
echo "Reading .env.local variables into script environment" | ||
export $(egrep -v '^#' $ENV_LOCAL_FILE_PATH | xargs) | ||
|
||
cd ../docker/postgres | ||
echo "Composing dexbooru database container from Docker Postgres image" | ||
docker-compose --env-file "../../.env.local" up -d | ||
docker-compose --env-file $ENV_LOCAL_FILE_PATH_DOCKER up -d | ||
|
||
cd ../redis | ||
echo "Composing dexbooru redis container from Docker Redis image" | ||
docker-compose --env-file "../../.env.local" up -d | ||
docker-compose --env-file $ENV_LOCAL_FILE_PATH_DOCKER up -d | ||
|
||
echo "Configuring permissions for the user called $DB_USER on the database called $DB_NAME" | ||
docker exec -it dexbooru-postgres psql -U ${DB_USER} -d ${DB_NAME} -c "ALTER USER ${DB_USER} WITH SUPERUSER;" | ||
docker exec -it dexbooru-postgres psql -U ${DB_USER} -d ${DB_NAME} -c "GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_USER};" | ||
docker exec -it dexbooru-postgres psql -U ${DB_USER} -d ${DB_NAME} -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA ${DB_SCHEMA} TO ${DB_USER};" | ||
|
||
cd ../../ | ||
echo "Migrating schemas and Seeding the database with mock data" | ||
yarn dbmigrate:dev | ||
yarn dbreset:dev | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import { getQueryParts } from '$lib/client/helpers/search'; | ||
import { normalizeQuery } from '$lib/shared/helpers/search'; | ||
export let query: string; | ||
export let fullText: string; | ||
const fullTextParts = getQueryParts(normalizeQuery(fullText), normalizeQuery(query)); | ||
</script> | ||
|
||
<p> | ||
{#each fullTextParts as { text, type }} | ||
<span class={type === 'highlight' ? 'bg-yellow-400' : ''}>{text}</span> | ||
{/each} | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<script lang="ts"> | ||
import { getGlobalSearchResults } from '$lib/client/api/search'; | ||
import { | ||
GLOBAL_SEARCH_INPUT_ELEMENT_ID, | ||
SEARCH_DEBOUNCE_TIMEOUT_MS | ||
} from '$lib/client/constants/search'; | ||
import { FAILURE_TOAST_OPTIONS } from '$lib/client/constants/toasts'; | ||
import { debounce, memoize } from '$lib/client/helpers/util'; | ||
import { searchModalActiveStore } from '$lib/client/stores/layout'; | ||
import { queryStore } from '$lib/client/stores/search'; | ||
import type { IAppSearchResult } from '$lib/shared/types/search'; | ||
import { toast } from '@zerodevx/svelte-toast'; | ||
import { Modal, Spinner } from 'flowbite-svelte'; | ||
import { onDestroy } from 'svelte'; | ||
import Searchbar from '../reusable/Searchbar.svelte'; | ||
import SearchResultsContainer from './SearchResultsContainer.svelte'; | ||
let currentSearchResults: IAppSearchResult | null = null; | ||
let searchResultsLoading = false; | ||
const searchModalUnsubsribe = searchModalActiveStore.subscribe((active) => { | ||
if (active) { | ||
const globalSearchInput = document.querySelector( | ||
`#${GLOBAL_SEARCH_INPUT_ELEMENT_ID}` | ||
) as HTMLInputElement | null; | ||
if (globalSearchInput) { | ||
globalSearchInput.focus(); | ||
} | ||
} else { | ||
currentSearchResults = null; | ||
} | ||
}); | ||
const fetchQueryResults = memoize(async (query: string) => { | ||
const response = await getGlobalSearchResults(query); | ||
if (response.ok) { | ||
return (await response.json()) as IAppSearchResult; | ||
} else { | ||
toast.push( | ||
'An unexpected error occured while retrieving the search results', | ||
FAILURE_TOAST_OPTIONS | ||
); | ||
return null; | ||
} | ||
}, true); | ||
const clearResultsOnEmptyQuery = (query: string) => { | ||
if (query.length === 0) { | ||
currentSearchResults = null; | ||
} | ||
}; | ||
const debouncedFetchQueryResults = debounce(async (query: string) => { | ||
searchResultsLoading = true; | ||
queryStore.set(query); | ||
currentSearchResults = query ? await fetchQueryResults(query as never) : null; | ||
searchResultsLoading = false; | ||
}, SEARCH_DEBOUNCE_TIMEOUT_MS) as (query: string) => void; | ||
onDestroy(() => { | ||
searchModalUnsubsribe(); | ||
}); | ||
</script> | ||
|
||
<Modal | ||
title="Find tags, artists, users and posts" | ||
open={$searchModalActiveStore} | ||
outsideclose | ||
class="w-screen" | ||
placement="top-center" | ||
on:close={() => searchModalActiveStore.set(false)} | ||
> | ||
<div class="flex relative"> | ||
<Searchbar | ||
inputElementId={GLOBAL_SEARCH_INPUT_ELEMENT_ID} | ||
isGlobal | ||
width="100%" | ||
placeholder="Enter your search query" | ||
queryInputHandler={debouncedFetchQueryResults} | ||
queryChangeHandler={clearResultsOnEmptyQuery} | ||
/> | ||
{#if searchResultsLoading} | ||
<Spinner color="pink" class="absolute top-2 right-2" size="7" /> | ||
{/if} | ||
</div> | ||
|
||
{#if currentSearchResults} | ||
<SearchResultsContainer results={currentSearchResults} /> | ||
{/if} | ||
</Modal> |
Oops, something went wrong.