Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trim titles and skip empty entries #15

Merged
merged 1 commit into from
May 23, 2021

Conversation

kevinjalbert
Copy link
Contributor

@kevinjalbert kevinjalbert commented May 22, 2021

This cleans up the visual output (no trailing whitespaces).

I noticed that a trailing null entry was coming out from the CSV
parsing of the SQLite dump. This was because we didn't have the
skipEmptyLines to avoid null records from showing up.

Copy link
Owner

@liamcain liamcain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for these fixes!

src/things.ts Outdated
@@ -50,22 +50,27 @@ export function buildTasksFromSQLRecords(
const tasks: Record<string, ITask> = {};
taskRecords.forEach(({ tag, ...task }) => {
const id = task.uuid;
if(!id) { return } // Sometimes a record with no data is present
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to filter out empty records inside getTasksFromThingsLogbook instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dug a bit more to figure why there were empty records. Turns out that the CSV dump from SQLite had an empty line at the ending of it. A null record would be present when Papa parsed the CSV.

To fix this I added the skipEmptyLines option in the Papa config. This means we don't have to have the defensive check here. I also modified the WHERE on the checklist query to exclude rows with an empty title.

Overall, I'm quite pleased with how this turned out now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Really great catch. The null record issue really had me for a loop and I never took the time to debug. Thanks for digging into this further 🙏

This cleans up the visual output (no trailing whitespaces).

I noticed that a trailing `null` entry was coming out from the CSV
parsing of the SQLite dump. This was because we didn't have the
`skipEmptyLines` to avoid `null` records from showing up.
@kevinjalbert kevinjalbert requested a review from liamcain May 23, 2021 01:19
@liamcain liamcain merged commit c7f3c44 into liamcain:main May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants