davidhealey / waistline

Libre calorie counter app for Android. Built with Cordova.
570 stars 69 forks source link

Question about answer to last question in FAQ #702

Open jmuff44xv opened 1 year ago

jmuff44xv commented 1 year ago

Regarding the last question in the FAQ,

https://github.com/davidhealey/waistline/blob/master/FAQ.md

"Do you plan to add support for the [XXX] online food database or API available in my country?",

Why are some of the numbers typed as quoted strings while others are not? Is this intentional, or is there any significance to it? e.g.:

"calories": 57.0,
"carbohydrates": "4.8",

The 57.0 is not in quotes, while the "4.8" is in quotes.

Would the import functionality be able to accept 600,000 food records, or is that too much? Would searching that slow down the app too much?

Is it stored internally as a database? How many MiB or GiB would such a 600k-record database be, approximately? Because, I figure, a database, like sqllite, would probably be bigger than the imported JSON file, for performance reasons.

jmuff44xv commented 1 year ago

Sorry, I just remembered I also wanted to ask: Is it OK for uniqueId to contain letters, e.g., "usda123456789", or must it be numerical?

I was initially thinking the answer was "yes" because the examples showed the values being supplied between quotation marks, suggesting that the values were strings. But then I became confused/doubtful when I saw that some of the floating point numbers are also between quotes, e.g., "4.8".

EmilJunker commented 1 year ago

I know I'm a bit late, but allow me to finally answer your questions 🙂

Why are some of the numbers typed as quoted strings while others are not? Is this intentional, or is there any significance to it?

There is no particular reason. In JavaScript it doesn't really matter whether you put numbers into strings or not.

Would the import functionality be able to accept 600,000 food records, or is that too much? Would searching that slow down the app too much?

Is it stored internally as a database? How many MiB or GiB would such a 600k-record database be, approximately?

I don't know if importing 600,000 items would work, but I think that's a bit too much. Waistline stores all data inside the indexedDB database of the WebView it's running in, and there is probably an upper limit for how much can be stored in there. But the only way to find out for sure if it works would be by trying it out...

Is it OK for uniqueId to contain letters, e.g., "usda123456789", or must it be numerical?

The uniqueId can include both letters and numbers. You could even put in special characters or emojis if you want 🥳