mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
* refactor: device asset entity to use modified time * chore: cleanup * refactor: remove album media dependency from hashservice * refactor: return updated copy of asset * add hash service tests * chore: rename hash batch constants * chore: log the number of assets processed during migration * chore: more logs * refactor: use lookup and more tests * use sort approach * refactor hash service to use for loop instead * refactor: rename to getByIds --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'package:immich_mobile/domain/interfaces/device_asset.interface.dart';
|
|
import 'package:immich_mobile/domain/models/device_asset.model.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/device_asset.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
|
import 'package:isar/isar.dart';
|
|
|
|
class IsarDeviceAssetRepository extends IsarDatabaseRepository
|
|
implements IDeviceAssetRepository {
|
|
final Isar _db;
|
|
|
|
const IsarDeviceAssetRepository(this._db) : super(_db);
|
|
|
|
@override
|
|
Future<void> deleteIds(List<String> ids) {
|
|
return transaction(() async {
|
|
await _db.deviceAssetEntitys.deleteAllByAssetId(ids.toList());
|
|
});
|
|
}
|
|
|
|
@override
|
|
Future<List<DeviceAsset>> getByIds(List<String> localIds) {
|
|
return _db.deviceAssetEntitys
|
|
.where()
|
|
.anyOf(localIds, (query, id) => query.assetIdEqualTo(id))
|
|
.findAll()
|
|
.then((value) => value.map((e) => e.toModel()).toList());
|
|
}
|
|
|
|
@override
|
|
Future<bool> updateAll(List<DeviceAsset> assetHash) {
|
|
return transaction(() async {
|
|
await _db.deviceAssetEntitys
|
|
.putAll(assetHash.map(DeviceAssetEntity.fromDto).toList());
|
|
return true;
|
|
});
|
|
}
|
|
}
|