Better frequency for people memories
This commit is contained in:
@@ -9,7 +9,7 @@ import "package:photos/models/memories/smart_memory.dart";
|
||||
import "package:photos/models/memories/smart_memory_constants.dart";
|
||||
import "package:photos/models/memories/trip_memory.dart";
|
||||
|
||||
const kPersonShowTimeout = Duration(days: 7 * 10);
|
||||
const kPersonShowTimeout = Duration(days: 16 * kMemoriesUpdateFrequencyDays);
|
||||
const kPersonAndTypeShowTimeout = Duration(days: 7 * 26);
|
||||
const kClipShowTimeout = Duration(days: 3 * 10);
|
||||
const kTripShowTimeout = Duration(days: 7 * 25);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Constants for computing smart memories
|
||||
const kMemoriesUpdateFrequency = Duration(days: 3);
|
||||
const kMemoriesUpdateFrequencyDays = 3;
|
||||
const kMemoriesUpdateFrequency = Duration(days: kMemoriesUpdateFrequencyDays);
|
||||
const kMemoriesMargin = Duration(days: 1);
|
||||
const kDayItself = Duration(days: 1);
|
||||
|
||||
@@ -422,6 +422,7 @@ class SmartMemoriesService {
|
||||
.map((p) => p.remoteID)
|
||||
.toList();
|
||||
orderedImportantPersonsID.shuffle(Random());
|
||||
final amountOfPersons = orderedImportantPersonsID.length;
|
||||
w?.log('orderedImportantPersonsID setup');
|
||||
|
||||
// Check if the user has assignmed "me"
|
||||
@@ -709,6 +710,12 @@ class SmartMemoriesService {
|
||||
w?.log('relevancy setup');
|
||||
|
||||
// Loop through the people (and memory types) and add based on rotation
|
||||
final shownPersonTimeout = Duration(
|
||||
days: min(
|
||||
kPersonShowTimeout.inDays,
|
||||
max(1, amountOfPersons) * kMemoriesUpdateFrequencyDays,
|
||||
),
|
||||
);
|
||||
peopleRotationLoop:
|
||||
for (final personID in orderedImportantPersonsID) {
|
||||
for (final memory in memoryResults) {
|
||||
@@ -721,7 +728,7 @@ class SmartMemoriesService {
|
||||
final shownDate =
|
||||
DateTime.fromMicrosecondsSinceEpoch(shownLog.lastTimeShown);
|
||||
final bool seenPersonRecently =
|
||||
currentTime.difference(shownDate) < kPersonShowTimeout;
|
||||
currentTime.difference(shownDate) < shownPersonTimeout;
|
||||
if (seenPersonRecently) continue peopleRotationLoop;
|
||||
}
|
||||
if (personToMemories[personID] == null) continue peopleRotationLoop;
|
||||
|
||||
Reference in New Issue
Block a user