mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Support querying getFileDescriptors with time range filter and offset
This commit is contained in:
parent
0bf19c9203
commit
2d5e470508
4 changed files with 34 additions and 8 deletions
|
@ -21,6 +21,7 @@ import 'package:nc_photos/entity/tag.dart';
|
|||
import 'package:nc_photos/exception_event.dart';
|
||||
import 'package:np_async/np_async.dart';
|
||||
import 'package:np_common/or_null.dart';
|
||||
import 'package:np_datetime/np_datetime.dart';
|
||||
import 'package:np_string/np_string.dart';
|
||||
import 'package:path/path.dart' as path_lib;
|
||||
|
||||
|
@ -307,7 +308,12 @@ class MockFileMemoryRepo extends FileRepo {
|
|||
class MockFileDataSource2 implements FileDataSource2 {
|
||||
@override
|
||||
Stream<List<FileDescriptor>> getFileDescriptors(
|
||||
Account account, String shareDirPath) {
|
||||
Account account,
|
||||
String shareDirPath, {
|
||||
TimeRange? timeRange,
|
||||
int? offset,
|
||||
int? limit,
|
||||
}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
@ -337,7 +343,12 @@ class MockFileMemoryDataSource2 extends MockFileDataSource2 {
|
|||
|
||||
@override
|
||||
Stream<List<FileDescriptor>> getFileDescriptors(
|
||||
Account account, String shareDirPath) async* {
|
||||
Account account,
|
||||
String shareDirPath, {
|
||||
TimeRange? timeRange,
|
||||
int? offset,
|
||||
int? limit,
|
||||
}) async* {
|
||||
yield files.where((f) {
|
||||
if (account.roots.any((r) => file_util.isOrUnderDirPath(
|
||||
f.fdPath, file_util.unstripPath(account, r)))) {
|
||||
|
|
|
@ -347,6 +347,8 @@ abstract class NpDb {
|
|||
String? location,
|
||||
bool? isFavorite,
|
||||
List<String>? mimes,
|
||||
TimeRange? timeRange,
|
||||
int? offset,
|
||||
int? limit,
|
||||
});
|
||||
|
||||
|
|
|
@ -402,6 +402,8 @@ extension SqliteDbFileExtension on SqliteDb {
|
|||
String? location,
|
||||
bool? isFavorite,
|
||||
List<String>? mimes,
|
||||
TimeRange? timeRange,
|
||||
int? offset,
|
||||
int? limit,
|
||||
}) async {
|
||||
_log.info(
|
||||
|
@ -414,6 +416,8 @@ extension SqliteDbFileExtension on SqliteDb {
|
|||
"location: $location, "
|
||||
"isFavorite: $isFavorite, "
|
||||
"mimes: $mimes, "
|
||||
"timeRange: $timeRange, "
|
||||
"offset: $offset, "
|
||||
"limit: $limit",
|
||||
);
|
||||
|
||||
|
@ -490,7 +494,12 @@ extension SqliteDbFileExtension on SqliteDb {
|
|||
}
|
||||
query.orderBy([OrderingTerm.desc(accountFiles.bestDateTime)]);
|
||||
if (limit != null) {
|
||||
query.limit(limit);
|
||||
query.limit(limit, offset: offset);
|
||||
}
|
||||
if (timeRange != null) {
|
||||
accountFiles.bestDateTime
|
||||
.isBetweenTimeRange(timeRange)
|
||||
?.let((e) => query.where(e));
|
||||
}
|
||||
return query
|
||||
.map((r) => FileDescriptor(
|
||||
|
|
|
@ -444,6 +444,8 @@ class NpDbSqlite implements NpDb {
|
|||
String? location,
|
||||
bool? isFavorite,
|
||||
List<String>? mimes,
|
||||
TimeRange? timeRange,
|
||||
int? offset,
|
||||
int? limit,
|
||||
}) async {
|
||||
final sqlObjs = await _db.use((db) async {
|
||||
|
@ -457,6 +459,8 @@ class NpDbSqlite implements NpDb {
|
|||
location: location,
|
||||
isFavorite: isFavorite,
|
||||
mimes: mimes,
|
||||
timeRange: timeRange,
|
||||
offset: offset,
|
||||
limit: limit,
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue