Remove old moments calculation logic
This commit is contained in:
@@ -3,7 +3,6 @@ import "dart:math";
|
||||
|
||||
import "package:flutter/cupertino.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:intl/intl.dart";
|
||||
import 'package:logging/logging.dart';
|
||||
import "package:path_provider/path_provider.dart";
|
||||
import "package:photos/core/configuration.dart";
|
||||
@@ -261,56 +260,6 @@ class SearchService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<GenericSearchResult>> getRandomMomentsSearchResults(
|
||||
BuildContext context,
|
||||
) async {
|
||||
try {
|
||||
final nonNullSearchResults = <GenericSearchResult>[];
|
||||
final randomYear = getRadomYearSearchResult();
|
||||
final randomMonth = getRandomMonthSearchResult(context);
|
||||
final randomDate = getRandomDateResults(context);
|
||||
final randomHoliday = getRandomHolidaySearchResult(context);
|
||||
|
||||
final searchResults = await Future.wait(
|
||||
[randomYear, randomMonth, randomDate, randomHoliday],
|
||||
);
|
||||
|
||||
for (GenericSearchResult? searchResult in searchResults) {
|
||||
if (searchResult != null) {
|
||||
nonNullSearchResults.add(searchResult);
|
||||
}
|
||||
}
|
||||
|
||||
return nonNullSearchResults;
|
||||
} catch (e) {
|
||||
_logger.severe("Error getting RandomMomentsSearchResult", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<GenericSearchResult?> getRadomYearSearchResult() async {
|
||||
for (var yearData in YearsData.instance.yearsData..shuffle()) {
|
||||
final List<EnteFile> filesInYear =
|
||||
await _getFilesInYear(yearData.duration);
|
||||
if (filesInYear.isNotEmpty) {
|
||||
return GenericSearchResult(
|
||||
ResultType.year,
|
||||
yearData.year,
|
||||
filesInYear,
|
||||
hierarchicalSearchFilter: TopLevelGenericFilter(
|
||||
filterName: yearData.year,
|
||||
occurrence: kMostRelevantFilter,
|
||||
filterResultType: ResultType.year,
|
||||
matchedUploadedIDs: filesToUploadedFileIDs(filesInYear),
|
||||
filterIcon: Icons.calendar_month_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
//todo this throws error
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<List<GenericSearchResult>> getMonthSearchResults(
|
||||
BuildContext context,
|
||||
String query,
|
||||
@@ -343,35 +292,6 @@ class SearchService {
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
Future<GenericSearchResult?> getRandomMonthSearchResult(
|
||||
BuildContext context,
|
||||
) async {
|
||||
final months = getMonthData(context)..shuffle();
|
||||
for (MonthData month in months) {
|
||||
final matchedFiles =
|
||||
await FilesDB.instance.getFilesCreatedWithinDurations(
|
||||
_getDurationsOfMonthInEveryYear(month.monthNumber),
|
||||
ignoreCollections(),
|
||||
order: 'DESC',
|
||||
);
|
||||
if (matchedFiles.isNotEmpty) {
|
||||
return GenericSearchResult(
|
||||
ResultType.month,
|
||||
month.name,
|
||||
matchedFiles,
|
||||
hierarchicalSearchFilter: TopLevelGenericFilter(
|
||||
filterName: month.name,
|
||||
occurrence: kMostRelevantFilter,
|
||||
filterResultType: ResultType.month,
|
||||
matchedUploadedIDs: filesToUploadedFileIDs(matchedFiles),
|
||||
filterIcon: Icons.calendar_month_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<List<GenericSearchResult>> getHolidaySearchResults(
|
||||
BuildContext context,
|
||||
String query,
|
||||
@@ -411,35 +331,6 @@ class SearchService {
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
Future<GenericSearchResult?> getRandomHolidaySearchResult(
|
||||
BuildContext context,
|
||||
) async {
|
||||
final holidays = getHolidays(context)..shuffle();
|
||||
for (var holiday in holidays) {
|
||||
final matchedFiles =
|
||||
await FilesDB.instance.getFilesCreatedWithinDurations(
|
||||
_getDurationsForCalendarDateInEveryYear(holiday.day, holiday.month),
|
||||
ignoreCollections(),
|
||||
order: 'DESC',
|
||||
);
|
||||
if (matchedFiles.isNotEmpty) {
|
||||
return GenericSearchResult(
|
||||
ResultType.event,
|
||||
holiday.name,
|
||||
matchedFiles,
|
||||
hierarchicalSearchFilter: TopLevelGenericFilter(
|
||||
filterName: holiday.name,
|
||||
occurrence: kMostRelevantFilter,
|
||||
filterResultType: ResultType.event,
|
||||
matchedUploadedIDs: filesToUploadedFileIDs(matchedFiles),
|
||||
filterIcon: Icons.event_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<List<GenericSearchResult>> getFileTypeResults(
|
||||
BuildContext context,
|
||||
String query,
|
||||
@@ -1334,56 +1225,6 @@ class SearchService {
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
Future<GenericSearchResult?> getRandomDateResults(
|
||||
BuildContext context,
|
||||
) async {
|
||||
final allFiles = await getAllFilesForSearch();
|
||||
if (allFiles.isEmpty) return null;
|
||||
|
||||
final length = allFiles.length;
|
||||
final randomFile = allFiles[Random().nextInt(length)];
|
||||
final creationTime = randomFile.creationTime!;
|
||||
|
||||
final originalDateTime = DateTime.fromMicrosecondsSinceEpoch(creationTime);
|
||||
final startOfDay = DateTime(
|
||||
originalDateTime.year,
|
||||
originalDateTime.month,
|
||||
originalDateTime.day,
|
||||
);
|
||||
|
||||
final endOfDay = DateTime(
|
||||
originalDateTime.year,
|
||||
originalDateTime.month,
|
||||
originalDateTime.day + 1,
|
||||
);
|
||||
|
||||
final durationOfDay = [
|
||||
startOfDay.microsecondsSinceEpoch,
|
||||
endOfDay.microsecondsSinceEpoch,
|
||||
];
|
||||
|
||||
final matchedFiles = await FilesDB.instance.getFilesCreatedWithinDurations(
|
||||
[durationOfDay],
|
||||
ignoreCollections(),
|
||||
order: 'DESC',
|
||||
);
|
||||
|
||||
final name = DateFormat.yMMMd(Localizations.localeOf(context).languageCode)
|
||||
.format(originalDateTime.toLocal());
|
||||
return GenericSearchResult(
|
||||
ResultType.event,
|
||||
name,
|
||||
matchedFiles,
|
||||
hierarchicalSearchFilter: TopLevelGenericFilter(
|
||||
filterName: name,
|
||||
occurrence: kMostRelevantFilter,
|
||||
filterResultType: ResultType.event,
|
||||
matchedUploadedIDs: filesToUploadedFileIDs(matchedFiles),
|
||||
filterIcon: Icons.event_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<GenericSearchResult>> getContactSearchResults(
|
||||
String query,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user