Food, sync and warmer updates from 2026-10-26
- Food: "All products" lists what's here first (My foods, the food database, kept products), then Open Food Facts; the start of a barcode (4+ digits) finds the products starting with it (dashboard, app, server search). - Food: My foods barcodes; entries follow edits of their food or meal, and meals made with a changed food are worked out again (nested meals too); a save that changes nothing isn't written. - Food: the week strip shows protein / carbs / fat per day, over-target calories in red; the header's arrows go by week, days swap in place with prefetch on hover; the app's arrows go by week, a sideways swipe by day. - Food search: stomach / žalúdok / pipotă find gizzards, kurací / pui chicken, morčací / curcan turkey. - Sync: tables a plugin makes after start-up are prepared at the next sync and their file read from the start once. - Warmers build pages as each admin account and wait while someone is using the dashboard; slow page builds are logged. - Stations: impossible sensor readings are dropped; chart ticks never fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fb3c01cdd7
commit
4193de4262
26 changed files with 704 additions and 111 deletions
40
app/test/food_barcode_test.dart
Normal file
40
app/test/food_barcode_test.dart
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// My foods with the pack's barcode (food_model.dart saveMyFood / myFoodsByBarcode = the dashboard's db.clean_food /
|
||||
// my_foods_by_barcode): kept, found by it (leading zeros or not), checked, one food per barcode, left alone when not given.
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dash_app/health/food_model.dart';
|
||||
import 'package:dash_app/sync/store.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
final store = SyncStore('${Directory.systemTemp.createTempSync('barcode').path}/d.db', 'test00000000');
|
||||
|
||||
test('kept and found by it', () {
|
||||
final (u, err) = saveMyFood(store, name: 'Chicory syrup (4Slim)', per100: {'kcal': 161, 'fiber': 71}, portions: [],
|
||||
barcode: '8595245311155');
|
||||
expect(err, isNull);
|
||||
expect(myFoodsByBarcode(store, '8595245311155').single.myUid, u);
|
||||
expect(myFoodsByBarcode(store, '08595245311155').single.name, 'Chicory syrup (4Slim)');
|
||||
expect(myFoodByUid(store, u!)!.barcode, '8595245311155');
|
||||
expect(myFoodsByBarcode(store, '1234567890123'), isEmpty);
|
||||
});
|
||||
|
||||
test('checked: digits only, 8–14, one food per barcode', () {
|
||||
expect(saveMyFood(store, name: 'A', per100: {'kcal': 1}, portions: [], barcode: '12ab5678').$2, 'A barcode is 8–14 digits.');
|
||||
expect(saveMyFood(store, name: 'B', per100: {'kcal': 1}, portions: [], barcode: '1234567').$2, 'A barcode is 8–14 digits.');
|
||||
expect(saveMyFood(store, name: 'C', per100: {'kcal': 1}, portions: [], barcode: '8595245311155').$2, contains('has that barcode already'));
|
||||
});
|
||||
|
||||
test('an edit without it keeps it; empty clears it; a deleted food is not found', () {
|
||||
final u = myFoodsByBarcode(store, '8595245311155').single.myUid!;
|
||||
saveMyFood(store, uid: u, name: 'Chicory syrup (4Slim)', per100: {'kcal': 160}, portions: []);
|
||||
expect(store.row('food.food', u)!['barcode'], '8595245311155');
|
||||
saveMyFood(store, uid: u, name: 'Chicory syrup (4Slim)', per100: {'kcal': 160}, portions: [], barcode: ' 8595245311155 ');
|
||||
expect(store.row('food.food', u)!['barcode'], '8595245311155');
|
||||
deleteMyFood(store, u);
|
||||
expect(myFoodsByBarcode(store, '8595245311155'), isEmpty);
|
||||
final (v, _) = saveMyFood(store, name: 'D', per100: {'kcal': 1}, portions: [], barcode: '8595245311155');
|
||||
saveMyFood(store, uid: v, name: 'D', per100: {'kcal': 1}, portions: [], barcode: '');
|
||||
expect(store.row('food.food', v!)!['barcode'], isNull);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue