diff --git a/src/sqlite.ts b/src/sqlite.ts index 947cab4..f9f7ff1 100644 --- a/src/sqlite.ts +++ b/src/sqlite.ts @@ -15,6 +15,7 @@ function parseCSV(csv: Buffer[]): T[] { dynamicTyping: true, header: true, newline: "\n", + skipEmptyLines: true, }).data; } diff --git a/src/things.ts b/src/things.ts index 5bdfc91..a888f95 100644 --- a/src/things.ts +++ b/src/things.ts @@ -50,11 +50,13 @@ export function buildTasksFromSQLRecords( const tasks: Record = {}; taskRecords.forEach(({ tag, ...task }) => { const id = task.uuid; + if (tasks[id]) { tasks[id].tags.push(tag); } else { tasks[id] = { ...task, + title: task.title.trimEnd(), subtasks: [], tags: [tag], }; @@ -65,7 +67,7 @@ export function buildTasksFromSQLRecords( const task = tasks[taskId]; const subtask = { completed: !!stopDate, - title, + title: title.trimEnd(), }; // checklist item might be completed before task @@ -100,7 +102,7 @@ async function getTasksFromThingsDb( ON TMTaskTag.tasks = TMTask.uuid LEFT JOIN TMTag ON TMTag.uuid = TMTaskTag.tags - LEFT JOIN TMArea + LEFT JOIN TMArea ON TMTask.area = TMArea.uuid WHERE TMTask.trashed = 0 @@ -126,6 +128,7 @@ async function getChecklistItemsThingsDb( TMChecklistItem WHERE stopDate > ${latestSyncTime} + AND title IS NOT "" ORDER BY stopDate LIMIT ${TASK_FETCH_LIMIT}