perf(history): coalesce index bumps and batch per-row exists lookups

This commit is contained in:
zarzet
2026-07-26 22:25:04 +07:00
parent 1cda88cafc
commit cbee637501
5 changed files with 69 additions and 21 deletions
+4 -2
View File
@@ -626,11 +626,13 @@ class HistoryDatabase {
String trackName,
String artistName,
) async {
final key = matchKeyFor(trackName, artistName);
if (key.isEmpty) return null;
final db = await database;
final rows = await db.query(
'history',
where: 'LOWER(track_name) = ? AND LOWER(artist_name) = ?',
whereArgs: [trackName.toLowerCase(), artistName.toLowerCase()],
where: 'match_key = ?',
whereArgs: [key],
orderBy: 'downloaded_at DESC',
limit: 1,
);