chore: refactor the way edits are joined

This commit is contained in:
bwees
2026-01-13 12:38:26 -06:00
parent 7baf58ef6d
commit 9a280b0140
10 changed files with 242 additions and 118 deletions
@@ -112,13 +112,16 @@ class DriftBackupRepository extends DriftDatabaseRepository {
query.where((lae) => lae.checksum.isNotNull());
}
final hasEdits = _db.assetEditEntity.id.isNotNull();
final assetsQuery = query.join([
leftOuterJoin(_db.remoteAssetEntity, _db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum)),
leftOuterJoin(_db.assetEditEntity, _db.assetEditEntity.assetId.equalsExp(_db.remoteAssetEntity.id)),
]);
leftOuterJoin(
_db.assetEditEntity,
_db.assetEditEntity.assetId.equalsExp(_db.remoteAssetEntity.id),
useColumns: false,
),
])..addColumns([hasEdits]);
return assetsQuery
.map((row) => row.readTable(_db.localAssetEntity).toDto(row.readTableOrNull(_db.assetEditEntity) != null))
.get();
return assetsQuery.map((row) => row.readTable(_db.localAssetEntity).toDto(isEdited: row.read(hasEdits)!)).get();
}
}