Fix query for start plan
If the WHERE IN query is in the first select, then we will have no results unless the person has already worked out today.
This commit is contained in:
parent
cd602cee33
commit
4e6de66f90
|
@ -168,13 +168,16 @@ export const countToday = async (name: string): Promise<number> => {
|
|||
|
||||
export const countMany = async (names: string[]): Promise<CountMany[]> => {
|
||||
const questions = names.map(_ => '?').join(',');
|
||||
console.log({questions, names});
|
||||
const select = `
|
||||
SELECT workouts.name, COUNT(sets.id) as total, sets.sets
|
||||
FROM (SELECT distinct name FROM sets) workouts
|
||||
FROM (
|
||||
SELECT distinct name FROM sets
|
||||
WHERE name IN (${questions})
|
||||
) workouts
|
||||
LEFT JOIN sets ON sets.name = workouts.name
|
||||
AND sets.created LIKE STRFTIME('%Y-%m-%d%%', 'now', 'localtime')
|
||||
AND NOT hidden
|
||||
WHERE sets.name IN (${questions})
|
||||
GROUP BY workouts.name;
|
||||
`;
|
||||
const [result] = await db.executeSql(select, names);
|
||||
|
|
Loading…
Reference in New Issue
Block a user