Skip to content

Commit

Permalink
fix: support limit on search
Browse files Browse the repository at this point in the history
forgot to commit
  • Loading branch information
feildmaster committed Jul 14, 2024
1 parent dace3a9 commit c2c5ea2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
15 changes: 14 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"enabled": true
},
"singleProjectMode": true
}
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"*.local"
]
}
]
}
5 changes: 3 additions & 2 deletions src/managers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import firebase from './firebase';

export type SearchParams = {
id?: string;
limit?: number;
mode?: GameMode;
name?: string;
soul?: 'ANY' | Soul;
Expand All @@ -30,6 +31,7 @@ const db = getFirestore(firebase);

export default async function search({
id = '0',
limit: lmt = 20,
mode = 'ANY',
name = '',
soul = 'ANY',
Expand Down Expand Up @@ -67,8 +69,7 @@ export default async function search({
const q = query(
collection(db, 'gamehistory'),
...constraints,
// TODO: custom limit depending on guest, sponsor, admin
limit(20),
limit(lmt),
).withConverter(converter);
const docs = await getDocs(q);

Expand Down
2 changes: 2 additions & 0 deletions src/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ declare global {
type Optional<T extends any[], O> = [...T, O?];

type DocumentKey = DocumentSnapshot['id'];

type ValueOf<T> = T[keyof T];
}
6 changes: 5 additions & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"*.js",
"*.ts",
".*.js",
"test"
"test",
"functions"
],
"exclude": [
"node_modules"
]
}

0 comments on commit c2c5ea2

Please sign in to comment.