setHideAppContent(bool hideContent) async {
diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock
index 6bcba72f52..3dde9823df 100644
--- a/mobile/pubspec.lock
+++ b/mobile/pubspec.lock
@@ -1657,7 +1657,7 @@ packages:
description:
path: "."
ref: ios_only
- resolved-ref: "70e163745e082b81235d7330b9d5e8c110ed68e4"
+ resolved-ref: "212b2cab85647c6d2ffee213dc3b875ef2bf6504"
url: "https://github.com/ente-io/onnxruntime.git"
source: git
version: "1.4.1"
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index 40b5a4a69c..0030a61e5c 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -12,7 +12,7 @@ description: ente photos application
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 0.9.48+948
+version: 0.9.49+949
publish_to: none
environment:
diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsx
index dec117fe7e..17c5da18a3 100644
--- a/web/apps/photos/src/components/Sidebar/Preferences.tsx
+++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx
@@ -156,10 +156,14 @@ const localeName = (locale: SupportedLocale) => {
case "es-ES":
return "Español";
case "pt-BR":
- return "Brazilian Portuguese";
+ return "Português Brasileiro";
case "ru-RU":
- return "Russian";
+ return "Русский";
case "pl-PL":
- return "Polish";
+ return "Polski";
+ case "it-IT":
+ return "Italiano";
+ case "lt-LT":
+ return "Lietuvių kalba";
}
};
diff --git a/web/packages/base/i18n.ts b/web/packages/base/i18n.ts
index 5067e5fc95..9c842829b7 100644
--- a/web/packages/base/i18n.ts
+++ b/web/packages/base/i18n.ts
@@ -28,6 +28,8 @@ export const supportedLocales = [
"pt-BR" /* Portuguese, Brazilian */,
"ru-RU" /* Russian */,
"pl-PL" /* Polish */,
+ "it-IT" /* Italian */,
+ "lt-LT" /* Lithuanian */,
] as const;
/** The type of {@link supportedLocales}. */
@@ -177,6 +179,10 @@ const closestSupportedLocale = (
return "ru-RU";
} else if (ls.startsWith("pl")) {
return "pl-PL";
+ } else if (ls.startsWith("it")) {
+ return "it-IT";
+ } else if (ls.startsWith("lt")) {
+ return "lt-LT";
}
}
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index f51d54168b..53e75234fc 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -410,7 +410,7 @@
"folder": "Folder",
"google_takeout": "Google takeout",
"DEDUPLICATE_FILES": "Deduplicate files",
- "NO_DUPLICATES_FOUND": "You've no duplicate files that can be cleared",
+ "NO_DUPLICATES_FOUND": "You have no duplicate files that can be cleared",
"FILES": "files",
"EACH": "each",
"DEDUPLICATE_BASED_ON_SIZE": "The following files were clubbed based on their sizes, please review and delete items you believe are duplicates",
diff --git a/web/packages/base/locales/it-IT/translation.json b/web/packages/base/locales/it-IT/translation.json
index f8a0597afb..d6174c9fbf 100644
--- a/web/packages/base/locales/it-IT/translation.json
+++ b/web/packages/base/locales/it-IT/translation.json
@@ -19,7 +19,7 @@
"ENTER_OTT": "Codice di verifica",
"RESEND_MAIL": "Reinvia codice",
"VERIFY": "Verifica",
- "generic_error": "",
+ "generic_error": "Qualcosa è andato storto",
"generic_error_retry": "Qualcosa è andato storto, per favore riprova",
"INVALID_CODE": "Codice di verifica non valido",
"EXPIRED_CODE": "Il tuo codice di verifica è scaduto",
diff --git a/web/packages/base/locales/lt-LT/translation.json b/web/packages/base/locales/lt-LT/translation.json
index 08ecc00403..36edac467b 100644
--- a/web/packages/base/locales/lt-LT/translation.json
+++ b/web/packages/base/locales/lt-LT/translation.json
@@ -10,7 +10,7 @@
"NEW_USER": "Naujas platformoje „Ente“",
"EXISTING_USER": "Esamas naudotojas",
"enter_name": "Įveskite vardą",
- "PUBLIC_UPLOADER_NAME_MESSAGE": "Pridėkite vardą, kad draugai žinotų, kam padėkoti už šias puikias nuotraukas!",
+ "PUBLIC_UPLOADER_NAME_MESSAGE": "Pridėkite vardą, kad draugai žinotų, kam padėkoti už šias puikias nuotraukas.",
"ENTER_EMAIL": "Įveskite el. pašto adresą",
"EMAIL_ERROR": "Įveskite tinkamą el. paštą.",
"required": "Privaloma",
@@ -37,7 +37,7 @@
"PASSPHRASE_HINT": "Slaptažodis",
"CONFIRM_PASSPHRASE": "Patvirtinti slaptažodį",
"REFERRAL_CODE_HINT": "Kaip išgirdote apie „Ente“? (nebūtina)",
- "REFERRAL_INFO": "Mes nesekame programų diegimų. Mums padėtų, jei pasakytumėte, kur mus radote!",
+ "REFERRAL_INFO": "Mes nesekame programų diegimų. Mums padėtų, jei pasakytumėte, kur mus radote.",
"PASSPHRASE_MATCH_ERROR": "Slaptažodžiai nesutampa.",
"welcome_to_ente_title": "Sveiki atvykę į „“",
"welcome_to_ente_subtitle": "Visapusiškai užšifruota nuotraukų saugykla ir bendrinimas",
@@ -83,7 +83,7 @@
"previous_key": "Ankstesnis (←)",
"next_key": "Sekantis (→)",
"title_photos": "„Ente“ nuotraukos",
- "title_auth": "„Ente“ tap. nust.",
+ "title_auth": "„Ente Auth“",
"title_accounts": "„Ente“ paskyros",
"UPLOAD_FIRST_PHOTO": "Įkelkite pirmąją nuotrauką",
"IMPORT_YOUR_FOLDERS": "Importuokite aplankus",
@@ -286,7 +286,7 @@
"SEND_OTT": "Siųsti OTP",
"EMAIl_ALREADY_OWNED": "El. paštas jau paimtas.",
"ETAGS_BLOCKED": "Mums nepavyko įkelti toliau esančių failų dėl jūsų naršyklės konfigūracijos.
Išjunkite visus priedus, kurie gali trukdyti „Ente“ naudoti „eTags“ dideliems failams įkelti, arba naudokite mūsų darbalaukio programą, kad galėtumėte patikimiau importuoti.
",
- "LIVE_PHOTOS_DETECTED": "",
+ "LIVE_PHOTOS_DETECTED": "Nuotraukų ir vaizdo įrašų failai iš Gyvosios nuotraukos buvo sujungti į vieną failą",
"RETRY_FAILED": "Pakartoti nepavykusius įkėlimus",
"FAILED_UPLOADS": "Nepavykę įkėlimai ",
"failed_uploads_hint": "Kai baigsis įkėlimas, bus parinktis bandyti tai pakartoti",
@@ -302,13 +302,13 @@
"TOO_LARGE_UPLOADS": "Dideli failai",
"LARGER_THAN_AVAILABLE_STORAGE_UPLOADS": "Nepakankama saugykla",
"LARGER_THAN_AVAILABLE_STORAGE_INFO": "Šie failai nebuvo įkelti, nes jie viršija jūsų saugyklos plano didžiausio dydžio ribą.",
- "TOO_LARGE_INFO": "",
- "THUMBNAIL_GENERATION_FAILED_INFO": "",
- "upload_to_album": "",
- "add_to_album": "",
+ "TOO_LARGE_INFO": "Šie failai nebuvo įkelti, nes jie viršija didžiausio failo dydžio ribą.",
+ "THUMBNAIL_GENERATION_FAILED_INFO": "Šie failai buvo įkelti, bet, deja, negalėjome sugeneruoti jų miniatiūrų.",
+ "upload_to_album": "Įkelti į albumą",
+ "add_to_album": "Pridėti į albumą",
"move_to_album": "Perkelti į albumą",
- "unhide_to_album": "",
- "restore_to_album": "",
+ "unhide_to_album": "Rodyti į albumą",
+ "restore_to_album": "Atkurti į albumą",
"section_all": "Viskas",
"section_uncategorized": "Nekategorizuoti",
"section_archive": "Archyvas",
@@ -320,87 +320,87 @@
"unarchive": "Išarchyvuoti",
"unarchive_album": "Išarchyvuoti albumą",
"hide_collection": "Slėpti albumą",
- "unhide_collection": "",
- "MOVE": "",
- "add": "",
- "REMOVE": "",
- "YES_REMOVE": "",
- "REMOVE_FROM_COLLECTION": "",
- "MOVE_TO_TRASH": "",
- "TRASH_FILES_MESSAGE": "",
- "TRASH_FILE_MESSAGE": "",
+ "unhide_collection": "Rodyti albumą",
+ "MOVE": "Perkelti",
+ "add": "Pridėti",
+ "REMOVE": "Pašalinti",
+ "YES_REMOVE": "Taip, pašalinti",
+ "REMOVE_FROM_COLLECTION": "Pašalinti iš albumo",
+ "MOVE_TO_TRASH": "Perkelti į šiukšlinę",
+ "TRASH_FILES_MESSAGE": "Pasirinkti failai bus pašalinti iš visų albumų ir perkelti į šiukšlinę.",
+ "TRASH_FILE_MESSAGE": "Failas bus pašalintas iš visų albumų ir perkeltas į šiukšlinę.",
"DELETE_PERMANENTLY": "Ištrinti negrįžtamai",
"RESTORE": "Atkurti",
- "empty_trash": "",
- "empty_trash_title": "",
- "empty_trash_message": "",
- "leave_album": "",
- "leave_shared_album_title": "",
- "leave_shared_album_message": "",
- "leave_shared_album": "",
- "NOT_FILE_OWNER": "",
- "CONFIRM_SELF_REMOVE_MESSAGE": "",
- "CONFIRM_SELF_AND_OTHER_REMOVE_MESSAGE": "",
+ "empty_trash": "Ištuštinti šiukšlinę",
+ "empty_trash_title": "Ištuštinti šiukšlinę?",
+ "empty_trash_message": "Šie failai bus negrįžtamai ištrinti iš jūsų „Ente“ paskyros.",
+ "leave_album": "Palikti albumą",
+ "leave_shared_album_title": "Palikti bendrinamą albumą?",
+ "leave_shared_album_message": "Paliksite albumą ir jis nebebus jums matomas.",
+ "leave_shared_album": "Taip, palikti",
+ "NOT_FILE_OWNER": "Negalite ištrinti failų bendrinamame albume.",
+ "CONFIRM_SELF_REMOVE_MESSAGE": "Pasirinkti elementai bus pašalinti iš šio albumo. Elementai, kurie yra tik šiame albume, bus perkelti į Nekategorizuoti.",
+ "CONFIRM_SELF_AND_OTHER_REMOVE_MESSAGE": "Kai kuriuos elementus, kuriuos šalinate, pridėjo kiti žmonės, todėl prarasite prieigą prie jų.",
"sort_by_creation_time_ascending": "Seniausią",
"sort_by_updation_time_descending": "Paskutinį kartą atnaujintą",
"sort_by_name": "Pavadinimą",
- "FIX_CREATION_TIME": "",
- "FIX_CREATION_TIME_IN_PROGRESS": "",
- "CREATION_TIME_UPDATED": "",
- "UPDATE_CREATION_TIME_NOT_STARTED": "",
- "UPDATE_CREATION_TIME_COMPLETED": "",
- "UPDATE_CREATION_TIME_COMPLETED_WITH_ERROR": "",
+ "FIX_CREATION_TIME": "Taisyti laiką",
+ "FIX_CREATION_TIME_IN_PROGRESS": "Pataisomas laikas",
+ "CREATION_TIME_UPDATED": "Atnaujintas failo laikas",
+ "UPDATE_CREATION_TIME_NOT_STARTED": "Pasirinkite parinktį, kurią norite naudoti",
+ "UPDATE_CREATION_TIME_COMPLETED": "Sėkmingai atnaujinti visi failai",
+ "UPDATE_CREATION_TIME_COMPLETED_WITH_ERROR": "Nepavyko atnaujinti kai kurių failų laiko. Pakartokite.",
"CAPTION_CHARACTER_LIMIT": "Ne daugiau kaip 5000 simbolių",
"DATE_TIME_ORIGINAL": "Exif: originali datos laikas",
"DATE_TIME_DIGITIZED": "Exif: skaitmeninta datos laikas",
"METADATA_DATE": "Exif: metaduomenų data",
"CUSTOM_TIME": "Pasirinktinis laikas",
- "REOPEN_PLAN_SELECTOR_MODAL": "",
- "OPEN_PLAN_SELECTOR_MODAL_FAILED": "",
+ "REOPEN_PLAN_SELECTOR_MODAL": "Iš naujo atidaryti planus",
+ "OPEN_PLAN_SELECTOR_MODAL_FAILED": "Nepavyko atidaryti planų.",
"sharing_details": "Bendrinimo išsami informacija",
- "modify_sharing": "",
- "ADD_COLLABORATORS": "",
- "ADD_NEW_EMAIL": "",
- "shared_with_people_count_zero": "",
- "shared_with_people_count_one": "",
- "shared_with_people_count": "",
- "participants_count_zero": "",
- "participants_count_one": "",
- "participants_count": "",
- "ADD_VIEWERS": "",
- "CHANGE_PERMISSIONS_TO_VIEWER": "",
- "CHANGE_PERMISSIONS_TO_COLLABORATOR": "",
- "CONVERT_TO_VIEWER": "",
- "CONVERT_TO_COLLABORATOR": "",
- "CHANGE_PERMISSION": "",
- "REMOVE_PARTICIPANT": "",
- "CONFIRM_REMOVE": "",
- "MANAGE": "",
- "ADDED_AS": "",
- "COLLABORATOR_RIGHTS": "",
- "REMOVE_PARTICIPANT_HEAD": "",
- "OWNER": "",
+ "modify_sharing": "Modifikuoti bendrinimą",
+ "ADD_COLLABORATORS": "Pridėti bendradarbių",
+ "ADD_NEW_EMAIL": "Pridėti naują el. paštą",
+ "shared_with_people_count_zero": "Bendrinti su konkrečiais žmonėmis",
+ "shared_with_people_count_one": "Bendrinta su žmogumi",
+ "shared_with_people_count": "Bendrinta su {{count, number}} žmonėmis (-ių)",
+ "participants_count_zero": "Nėra dalyvių",
+ "participants_count_one": "Dalyvis",
+ "participants_count": "{count, number} dalyviai (-ų)",
+ "ADD_VIEWERS": "Pridėti žiūrėtojus",
+ "CHANGE_PERMISSIONS_TO_VIEWER": "{{selectedEmail}} negalės pridėti daugiau nuotraukų į albumą.
Jie vis tiek galės pašalinti savo pridėtas nuotraukas
",
+ "CHANGE_PERMISSIONS_TO_COLLABORATOR": "{{selectedEmail}} galės pridėti nuotraukų į albumą",
+ "CONVERT_TO_VIEWER": "Taip, keisti į žiūrėtoją",
+ "CONVERT_TO_COLLABORATOR": "Taip, keisti į bendradarbį",
+ "CHANGE_PERMISSION": "Keisti leidimą?",
+ "REMOVE_PARTICIPANT": "Pašalinti?",
+ "CONFIRM_REMOVE": "Taip, pašalinti",
+ "MANAGE": "Tvarkyti",
+ "ADDED_AS": "Pridėta kaip",
+ "COLLABORATOR_RIGHTS": "Bendradarbiai gali pridėti nuotraukų ir vaizdo įrašų į bendrintą albumą",
+ "REMOVE_PARTICIPANT_HEAD": "Pašalinti dalyvį",
+ "OWNER": "Savininkas",
"COLLABORATORS": "Bendradarbiai",
"ADD_MORE": "Pridėti daugiau",
"VIEWERS": "Žiūrėtojai",
- "OR_ADD_EXISTING": "",
- "REMOVE_PARTICIPANT_MESSAGE": "",
- "NOT_FOUND": "",
- "LINK_EXPIRED": "",
- "LINK_EXPIRED_MESSAGE": "",
+ "OR_ADD_EXISTING": "Arba pasirinkite esamą",
+ "REMOVE_PARTICIPANT_MESSAGE": "{{selectedEmail}} bus pašalintas iš albumo.
Visos jų pridėtos nuotraukos taip pat bus pašalintos iš albumo
",
+ "NOT_FOUND": "404 – nerasta.",
+ "LINK_EXPIRED": "Nuoroda nebegalioja",
+ "LINK_EXPIRED_MESSAGE": "Ši nuoroda nebegalioja arba yra išjungta.",
"MANAGE_LINK": "Tvarkyti nuorodą",
- "LINK_TOO_MANY_REQUESTS": "",
+ "LINK_TOO_MANY_REQUESTS": "Atsiprašome. Šis albumas buvo peržiūrėtas per daug įrenginiuose.",
"FILE_DOWNLOAD": "Leisti atsisiuntimus",
- "link_password_lock": "",
- "PUBLIC_COLLECT": "",
- "LINK_DEVICE_LIMIT": "",
- "NO_DEVICE_LIMIT": "",
- "LINK_EXPIRY": "",
- "NEVER": "",
- "DISABLE_FILE_DOWNLOAD": "",
- "DISABLE_FILE_DOWNLOAD_MESSAGE": "",
- "SHARED_USING": "",
- "SHARING_REFERRAL_CODE": "",
+ "link_password_lock": "Slaptažodžio užraktas",
+ "PUBLIC_COLLECT": "Leisti pridėti nuotraukų",
+ "LINK_DEVICE_LIMIT": "Įrenginių riba",
+ "NO_DEVICE_LIMIT": "Jokio",
+ "LINK_EXPIRY": "Nuorodos galiojimo laikas",
+ "NEVER": "Niekada",
+ "DISABLE_FILE_DOWNLOAD": "Išjungti atsisiuntimą",
+ "DISABLE_FILE_DOWNLOAD_MESSAGE": "Ar tikrai norite išjungti failų atsisiuntimo mygtuką?
Žiūrėtojai vis tiek gali daryti ekrano kopijas arba išsaugoti nuotraukų kopijas naudojant išorinius įrankius.
",
+ "SHARED_USING": "Bendrinta naudojant ",
+ "SHARING_REFERRAL_CODE": "Naudokite kodą {{{referralCode}}, kad gautumėte 10 GB nemokamai",
"LIVE": "GYVAI",
"DISABLE_PASSWORD": "Išjungti slaptažodžio užraktą",
"DISABLE_PASSWORD_MESSAGE": "Ar tikrai norite išjungti slaptažodžio užraktą?",
@@ -630,7 +630,7 @@
"passkey_login_credential_hint": "Jei slaptaraktai yra kitame įrenginyje, galite atidaryti šį puslapį tame įrenginyje ir patvirtinti.",
"passkeys_not_supported": "Šioje naršyklėje nepalaikomi slaptaraktai.",
"try_again": "Bandyti dar kartą",
- "check_status": "Patikrinti būseną",
+ "check_status": "Tikrinti būseną",
"passkey_login_instructions": "Sekite žingsnius iš naršyklės, kad tęstumėte prisijungimą.",
"passkey_login": "Prisijungti su slaptaraktu",
"passkey": "Slaptaraktas",
diff --git a/web/packages/base/locales/nl-NL/translation.json b/web/packages/base/locales/nl-NL/translation.json
index 04bf6b22af..3bfa0f9d9b 100644
--- a/web/packages/base/locales/nl-NL/translation.json
+++ b/web/packages/base/locales/nl-NL/translation.json
@@ -19,7 +19,7 @@
"ENTER_OTT": "Verificatiecode",
"RESEND_MAIL": "Code opnieuw versturen",
"VERIFY": "Verifiëren",
- "generic_error": "",
+ "generic_error": "Er ging iets mis",
"generic_error_retry": "Er is iets fout gegaan, probeer het opnieuw",
"INVALID_CODE": "Ongeldige verificatiecode",
"EXPIRED_CODE": "Uw verificatiecode is verlopen",
@@ -48,7 +48,7 @@
"enter_file_name": "Bestandsnaam",
"close": "Sluiten",
"no": "Nee",
- "nothing_here": "",
+ "nothing_here": "Hier is nog niets te zien",
"upload": "Uploaden",
"import": "Importeren",
"add_photos": "Foto's toevoegen",
diff --git a/web/packages/new/photos/services/ml/people.ts b/web/packages/new/photos/services/ml/people.ts
index 16b36a0232..80f8a5795c 100644
--- a/web/packages/new/photos/services/ml/people.ts
+++ b/web/packages/new/photos/services/ml/people.ts
@@ -363,6 +363,7 @@ export interface PersonSuggestionsAndChoices {
export const _suggestionsAndChoicesForPerson = async (
person: CGroupPerson,
): Promise => {
+ console.time("prep");
const startTime = Date.now();
const personClusters = person.cgroup.data.assigned;
@@ -391,12 +392,13 @@ export const _suggestionsAndChoicesForPerson = async (
.filter((e) => !!e);
// Randomly sample faces to limit the O(n^2) cost.
- const sampledPersonFaceEmbeddings = shuffled(personFaceEmbeddings).slice(
- 0,
- 100,
- );
+ const sampledPersonEmbeddings = randomSample(personFaceEmbeddings, 50);
- const suggestedClusters: FaceCluster[] = [];
+ console.timeEnd("prep");
+
+ console.time("loop");
+
+ const candidateClustersAndSimilarity: [FaceCluster, number][] = [];
for (const cluster of clusters) {
const { id, faces } = cluster;
@@ -405,23 +407,53 @@ export const _suggestionsAndChoicesForPerson = async (
if (personClusterIDs.has(id)) continue;
if (ignoredClusterIDs.has(id)) continue;
- let suggest = false;
- for (const fi of faces) {
- const ei = embeddingByFaceID.get(fi);
- if (!ei) continue;
- for (const ej of sampledPersonFaceEmbeddings) {
- const csim = dotProduct(ei, ej);
- if (csim >= 0.6) {
- suggest = true;
- break;
+ if (process.env.NEXT_PUBLIC_ENTE_WIP_CL_TODO) {
+ /* direct compare method TODO-Cluster remove me */
+ let suggest = false;
+ for (const fi of faces) {
+ const ei = embeddingByFaceID.get(fi);
+ if (!ei) continue;
+ for (const ej of sampledPersonEmbeddings) {
+ const csim = dotProduct(ei, ej);
+ if (csim >= 0.6) {
+ suggest = true;
+ break;
+ }
+ }
+ if (suggest) break;
+ }
+
+ if (suggest) candidateClustersAndSimilarity.push([cluster, 0]);
+ } else {
+ const sampledOtherEmbeddings = randomSample(faces, 50)
+ .map((id) => embeddingByFaceID.get(id))
+ .filter((e) => !!e);
+
+ /* cosine similarities */
+ const csims: number[] = [];
+ for (const other of sampledOtherEmbeddings) {
+ for (const embedding of sampledPersonEmbeddings) {
+ csims.push(dotProduct(embedding, other));
}
}
- if (suggest) break;
- }
+ csims.sort();
- if (suggest) suggestedClusters.push(cluster);
+ if (csims.length == 0) continue;
+
+ const medianSim = ensure(csims[Math.floor(csims.length / 2)]);
+ if (medianSim > 0.48) {
+ candidateClustersAndSimilarity.push([cluster, medianSim]);
+ }
+ }
}
+ console.timeEnd("loop");
+
+ console.time("post");
+
+ candidateClustersAndSimilarity.sort(([, a], [, b]) => b - a);
+ const suggestedClusters = candidateClustersAndSimilarity.map(([c]) => c);
+
// Annotate the clusters with the information that the UI needs to show its
// preview faces.
@@ -449,21 +481,28 @@ export const _suggestionsAndChoicesForPerson = async (
if (previewFaces.length == 4) break;
}
+ if (previewFaces.length == 0) return undefined;
+
return { ...cluster, previewFaces };
};
+ const toPreviewableList = (clusters: FaceCluster[]) =>
+ clusters.map(toPreviewable).filter((p) => !!p);
+
const sortBySize = (entries: { faces: unknown[] }[]) =>
entries.sort((a, b) => b.faces.length - a.faces.length);
- const acceptedChoices = personClusters
- .map(toPreviewable)
- .map((p) => ({ ...p, accepted: true }));
+ const acceptedChoices = toPreviewableList(personClusters).map((p) => ({
+ ...p,
+ accepted: true,
+ }));
sortBySize(acceptedChoices);
- const ignoredChoices = ignoredClusters
- .map(toPreviewable)
- .map((p) => ({ ...p, accepted: false }));
+ const ignoredChoices = toPreviewableList(ignoredClusters).map((p) => ({
+ ...p,
+ accepted: false,
+ }));
// Ensure that the first item in the choices is not an ignored one, even if
// that is what we'd have ended up with if we sorted by size.
@@ -474,9 +513,11 @@ export const _suggestionsAndChoicesForPerson = async (
const choices = [firstChoice, ...restChoices];
- sortBySize(suggestedClusters);
+ // sortBySize(suggestedClusters);
// Limit to the number of suggestions shown in a single go.
- const suggestions = suggestedClusters.slice(0, 80).map(toPreviewable);
+ const suggestions = toPreviewableList(suggestedClusters.slice(0, 80));
+
+ console.timeEnd("post");
log.info(
`Generated ${suggestions.length} suggestions for ${person.id} (${Date.now() - startTime} ms)`,
@@ -484,3 +525,6 @@ export const _suggestionsAndChoicesForPerson = async (
return { choices, suggestions };
};
+
+const randomSample = (items: T[], n: number) =>
+ items.length < n ? items : shuffled(items).slice(0, n);