fixes before build
This commit is contained in:
@@ -392,10 +392,11 @@ class ProductRepository extends ChangeNotifier {
|
||||
ProductSort sort = ProductSort.name,
|
||||
}) async {
|
||||
final db = await _database;
|
||||
final favouritesOnly = sort == ProductSort.favourite;
|
||||
final orderBy = switch (sort) {
|
||||
ProductSort.name => 'name COLLATE NOCASE ASC',
|
||||
ProductSort.preferred => 'times_seen DESC, name COLLATE NOCASE ASC',
|
||||
ProductSort.start => 'favourite DESC, name COLLATE NOCASE ASC',
|
||||
ProductSort.favourite => 'name COLLATE NOCASE ASC',
|
||||
};
|
||||
final rows = await db.rawQuery('''
|
||||
SELECT
|
||||
@@ -409,6 +410,7 @@ class ProductRepository extends ChangeNotifier {
|
||||
LIMIT 1
|
||||
) AS display_price
|
||||
FROM products
|
||||
${favouritesOnly ? 'WHERE favourite = 1' : ''}
|
||||
ORDER BY $orderBy
|
||||
''');
|
||||
return rows.map(Product.fromMap).toList();
|
||||
@@ -1436,6 +1438,21 @@ class ProductRepository extends ChangeNotifier {
|
||||
return rows.map(Supermarket.fromMap).toList();
|
||||
}
|
||||
|
||||
/// Store names from newest trip to oldest, unique.
|
||||
Future<List<String>> getLastTripSupermarkets() async {
|
||||
final db = await _database;
|
||||
final rows = await db.rawQuery('''
|
||||
SELECT supermarket
|
||||
FROM shops
|
||||
GROUP BY supermarket
|
||||
ORDER BY MAX(shopped_at) DESC, MAX(id) DESC
|
||||
''');
|
||||
return [
|
||||
for (final row in rows)
|
||||
if (row['supermarket'] is String) row['supermarket']! as String,
|
||||
];
|
||||
}
|
||||
|
||||
Future<Supermarket> addSupermarket({
|
||||
required String name,
|
||||
required int colorValue,
|
||||
|
||||
Reference in New Issue
Block a user