Kontaktok listázási hibájának javítása, csv export

This commit is contained in:
2026-07-08 22:13:30 +02:00
parent 7cd682fe59
commit 1ab656585b
9 changed files with 262 additions and 19 deletions
+29 -2
View File
@@ -1294,6 +1294,7 @@ class AppDatabase {
await db.execute('''
CREATE TABLE IF NOT EXISTS contacts_outbox (
local_uuid TEXT PRIMARY KEY,
project_id TEXT NOT NULL,
name TEXT NOT NULL,
address TEXT NOT NULL DEFAULT '',
phone TEXT NOT NULL DEFAULT '',
@@ -1302,6 +1303,8 @@ class AppDatabase {
created_at TEXT NOT NULL
)
''');
await db.execute('CREATE INDEX IF NOT EXISTS idx_contacts_outbox_project '
'ON contacts_outbox(project_id)');
}
Future<void> insertPendingContact(Map<String, dynamic> row) async {
@@ -1309,8 +1312,18 @@ class AppDatabase {
await db.insert('contacts_outbox', row);
}
Future<List<Map<String, dynamic>>> listPendingContacts() async {
/// [projectId] NÉLKÜL (a flush-hoz) MINDEN várólistás sort ad vissza —
/// a feltöltés projekttől függetlenül fusson. [projectId]-vel (a UI
/// listához) csak az adott projekt pending sorait.
Future<List<Map<String, dynamic>>> listPendingContacts(
{String? projectId}) async {
final db = await database;
if (projectId != null) {
return db.query('contacts_outbox',
where: 'project_id = ?',
whereArgs: [projectId],
orderBy: 'created_at ASC');
}
return db.query('contacts_outbox', orderBy: 'created_at ASC');
}
@@ -1327,10 +1340,24 @@ class AppDatabase {
where: 'local_uuid = ?', whereArgs: [localUuid]);
}
Future<int> countPendingContacts() async {
Future<int> countPendingContacts({String? projectId}) async {
final db = await database;
if (projectId != null) {
return Sqflite.firstIntValue(await db.rawQuery(
'SELECT COUNT(*) FROM contacts_outbox WHERE project_id = ?',
[projectId])) ??
0;
}
return Sqflite.firstIntValue(
await db.rawQuery('SELECT COUNT(*) FROM contacts_outbox')) ??
0;
}
// Future<void> testOnly() async {
// final db = await database;
// await db.execute(
// "ALTER TABLE contacts_outbox ADD COLUMN project_id TEXT NOT NULL DEFAULT ''");
// await db.execute('CREATE INDEX IF NOT EXISTS idx_contacts_outbox_project '
// 'ON contacts_outbox(project_id)');
// }
}