timeline go brrrrr

This commit is contained in:
shenlong-tanwen
2025-03-19 00:03:45 +05:30
parent b82b9a550a
commit 6311ecadd4
12 changed files with 323 additions and 249 deletions
@@ -16,16 +16,16 @@ class AssetRepository with LogMixin implements IAssetRepository {
@override
Future<bool> upsertAll(Iterable<Asset> assets) async {
try {
await _db.txn(() async => await _db.batch((batch) {
final rows = assets.map(_toEntity);
for (final row in rows) {
batch.insert(
_db.asset,
row,
onConflict: DoUpdate((_) => row, target: [_db.asset.hash]),
);
}
}));
await _db.batch((batch) {
final rows = assets.map(_toEntity);
for (final row in rows) {
batch.insert(
_db.asset,
row,
onConflict: DoUpdate((_) => row, target: [_db.asset.hash]),
);
}
});
return true;
} catch (e, s) {
@@ -18,11 +18,10 @@ class DeviceAssetToHashRepository
@override
Future<bool> upsertAll(Iterable<DeviceAssetToHash> assetHash) async {
try {
await _db.txn(() async =>
await _db.batch((batch) => batch.insertAllOnConflictUpdate(
_db.deviceAssetToHash,
assetHash.map(_toEntity),
)));
await _db.batch((batch) => batch.insertAllOnConflictUpdate(
_db.deviceAssetToHash,
assetHash.map(_toEntity),
));
return true;
} catch (e, s) {
@@ -46,9 +46,9 @@ class LogRepository implements ILogRepository {
@override
Future<bool> createAll(Iterable<LogMessage> logs) async {
try {
await _db.txn(() async => await _db.batch((b) {
b.insertAll(_db.logs, logs.map(_toEntity));
}));
await _db.batch((b) {
b.insertAll(_db.logs, logs.map(_toEntity));
});
return true;
} catch (e) {
debugPrint("Error while adding a log to the DB - $e");