mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-12 18:43:45 +00:00
feat(#46): Componentise the boxes view
This commit is contained in:
@@ -3,7 +3,11 @@ import CatchRecordModel, { type CatchRecord } from '$lib/models/CatchRecord';
|
||||
import { CombinedData } from '$lib/models/CombinedData';
|
||||
|
||||
class CombinedDataRepository {
|
||||
async findAllCombinedData(enableForms: boolean = true): Promise<CombinedData[]> {
|
||||
async findAllCombinedData(
|
||||
enableForms: boolean = true,
|
||||
region: string = '',
|
||||
game: string = ''
|
||||
): Promise<CombinedData[]> {
|
||||
const pipeline: any[] = [
|
||||
{
|
||||
$lookup: {
|
||||
@@ -36,6 +40,22 @@ class CombinedDataRepository {
|
||||
});
|
||||
}
|
||||
|
||||
if (region.length > 0) {
|
||||
pipeline.unshift({
|
||||
$match: {
|
||||
regionToCatchIn: region
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (game.length > 0) {
|
||||
pipeline.unshift({
|
||||
$match: {
|
||||
gamesToCatchIn: { $in: [game] }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const combinedData: CombinedData[] = await PokedexEntryModel.aggregate(pipeline).exec();
|
||||
|
||||
// Filter out entries with no catch records
|
||||
|
||||
Reference in New Issue
Block a user