Skip to content

Commit

Permalink
correct sqlite code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Moschkin committed Dec 6, 2023
1 parent 45efde5 commit 1436edd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/logic/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,24 @@ export async function voyageRawByRange(startDate?: Date, endDate?: Date, crewMat
}

const where = {
voyageDate: [
{ [Op.gte]: startDate },
{ [Op.lte]: endDate }
],
voyageDate: {
[Op.and]: [
{ [Op.gte]: startDate },
{ [Op.lte]: endDate }
]
},
crew: undefined as any
};

if (crewMatch) {
where.crew = { [Op.or]: [] as any[] };
for (let crew of crewMatch) {
where.crew[Op.or].push({ [Op.like]: `%"${crew}"%`})
if (crewMatch.length > 1) {
where.crew = { [Op.or]: [] as any[] };
for (let crew of crewMatch) {
where.crew[Op.or].push({ [Op.like]: `%"${crew}"%`})
}
}
else {
where.crew = { [Op.like]: `%"${crewMatch[0]}"%` };
}
}
else {
Expand Down

0 comments on commit 1436edd

Please sign in to comment.