feat: add equality operators, make history screen paginated, random performance updates

This commit is contained in:
2026-07-29 18:10:46 +02:00
parent da5588cd1c
commit 031a618220
22 changed files with 702 additions and 79 deletions
+69
View File
@@ -254,4 +254,73 @@ class DevMenuViewModel extends ChangeNotifier {
notifyListeners();
}
}
Future<void> generateMockOrders({int count = 100}) async {
_isLoading = true;
notifyListeners();
try {
final products = await productService.getProducts();
if (products.isEmpty) {
_lastAction = 'No products available — seed demo data first';
return;
}
final uuid = const Uuid();
final customerNames = [
'Alice', 'Bob', 'Charlie', 'Diana', 'Eve', 'Frank',
'Grace', 'Hank', 'Ivy', 'Jack', 'Kate', 'Leo',
'Mia', 'Noah', 'Olivia', 'Pete', 'Quinn', 'Rose',
'Sam', 'Tina', 'Umar', 'Vera', 'Wes', 'Xena',
'Yves', 'Zara',
];
await database.transaction(() async {
for (var i = 0; i < count; i++) {
final customer = customerNames[i % customerNames.length];
final closedTabId = uuid.v4();
final itemCount = 1 + (i % 5);
final closedAt = DateTime.now().subtract(
Duration(
days: i % 90,
hours: i % 24,
minutes: i % 60,
),
);
await database.into(database.closedTabs).insert(
ClosedTabsCompanion.insert(
id: closedTabId,
originalTabId: uuid.v4(),
customerName: customer,
closedAt: closedAt,
),
);
for (var j = 0; j < itemCount; j++) {
final product = products[(i + j) % products.length];
final quantity = 1 + ((i * 7 + j * 13) % 6);
await database.into(database.closedTabItems).insert(
ClosedTabItemsCompanion.insert(
id: uuid.v4(),
closedTabId: closedTabId,
productId: product.id,
productName: product.name,
quantity: quantity,
unitPriceInCents: product.priceInCents,
),
);
}
}
});
_lastAction = 'Generated $count mock orders across '
'${customerNames.length} customers';
} finally {
_isLoading = false;
notifyListeners();
}
}
}