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

check for empty array of values #1070

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kenziebourn
Copy link

Related issue

Closes #1068

Context / Background

A user can import a database which has an array of empty values, and the overall balance incorrectly updates. When importing a database, I expected that the app would check for an array of empty values before validating, and fail if there is no values in the database file. And even if the app should accept empty values, the overall time balance shouldn't be affected since there is no times entered.

What change is being introduced by this PR?

  • How did you approach this problem?
    I thought about what has to be changed in the logic of the validEntry function in the import-export.js file so that users can't upload an empty database file which automatically would fix the issue of seeing an incorrect balance update.
  • What changes did you make to achieve the goal?
    I have added a check for an array of empty values before validating. The user can now only import a database which actually has values.
  • What are the indirect and direct consequences of the change?
    The function's update ensures data validation by rejecting entries with empty value arrays, maintaining data integrity. This change also indirectly prevents errors in other application parts relying on entries with at least one time value, thus avoiding potential inaccuracies or failures in calculations.

How will this be tested?

After running the Time To Leave App, a user will not be able to import an empty database. To test this, create a testdb.ttldb file with the contents:
[ { "type": "flexible", "date": "2023-05-21", "values": [] } ]

After attempting to import the file, the app should say:
image

Copy link
Collaborator

@tupaschoal tupaschoal left a comment

Choose a reason for hiding this comment

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

Does this change how unfilled time entries work? Example:

You add times for a monday, skip tuesday and add wednesday. I'd expect the balance to be negative, is it still after this change?

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.

Empty database import updates overall balance
2 participants