mirror of
https://github.com/psforever/PSFPortal.git
synced 2026-01-19 18:14:45 +00:00
Fix case insensitive search and display
This commit is contained in:
parent
0e4123fe98
commit
817796e181
11
api/db.js
11
api/db.js
|
|
@ -340,6 +340,13 @@ export async function get_account_logins(account_id, pagination) {
|
|||
|
||||
export async function search(term, pagination) {
|
||||
const start_id = (pagination.page-1)*pagination.items_per_page;
|
||||
|
||||
term = term.replace(/%/g, "");
|
||||
|
||||
if (term.length < 3) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const values = ['%'+term.toUpperCase()+'%', start_id, pagination.items_per_page];
|
||||
|
||||
try {
|
||||
|
|
@ -347,8 +354,8 @@ export async function search(term, pagination) {
|
|||
'WHERE upper(username) LIKE $1 '+
|
||||
` ORDER BY username OFFSET $2 LIMIT $3`, values);
|
||||
const characters = await pool.query('SELECT id, name, account_id, faction_id FROM characters ' +
|
||||
'WHERE name LIKE $1 '+
|
||||
` ORDER BY upper(name) OFFSET $2 LIMIT $3`, values);
|
||||
'WHERE upper(name) LIKE $1 '+
|
||||
` ORDER BY name OFFSET $2 LIMIT $3`, values);
|
||||
|
||||
pagination.item_count = 100;
|
||||
pagination.page_count = Math.ceil(pagination.item_count / pagination.items_per_page);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@
|
|||
<button type="submit" class="btn btn-primary mb-2">Search</button>
|
||||
</form>
|
||||
{#if results}
|
||||
{#if results.length > 0}
|
||||
<p>{results.length} results found.</p>
|
||||
{:else}
|
||||
<p>No results found.</p>
|
||||
{/if}
|
||||
<ol>
|
||||
{#each results as result, i}
|
||||
{#if result.type == "account"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue