Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Sketch

Manav Rathi5fa719f3e9e5
diff --git a/web/apps/photos/src/services/entityService.ts b/web/apps/photos/src/services/entityService.ts
index 401819b110..1aeba5ff44 100644
--- a/web/apps/photos/src/services/entityService.ts
+++ b/web/apps/photos/src/services/entityService.ts
@@ -25,7 +25,7 @@ import { getLatestVersionEntities } from "utils/entity";
*
* These diff API calls return all items whose updated at is greater
* (non-inclusive) than the timestamp we provide. So there is no mechanism for
- * pagination of items which have the same exact updated at.
+ * pagination of items which have the exact same updated at.
*
* Conceptually, it may happen that there are more items than the limit we've
* provided, but there are practical safeguards.
diff --git a/web/packages/new/photos/services/entity.ts b/web/packages/new/photos/services/entity.ts
new file mode 100644
index 0000000000..363417293f
--- /dev/null
+++ b/web/packages/new/photos/services/entity.ts
@@ -0,0 +1,60 @@
+/**
+ * Entities are predefined lists of otherwise arbitrary data that the user can
+ * store for their account.
+ *
+ * e.g. location tags, people in their photos.
+ */
+export type EntityType =
+ /**
+ * A new version of the Person entity where the data is gzipped before
+ * encryption.
+ */
+ "person_v2";
+
+/**
+ * The maximum number of items to fetch in a single diff
+ *
+ * [Note: Limit of returned items in /diff requests]
+ *
+ * The various GET /diff API methods, which tell the client what all has changed
+ * since a timestamp (provided by the client) take a limit parameter.
+ *
+ * These diff API calls return all items whose updated at is greater
+ * (non-inclusive) than the timestamp we provide. So there is no mechanism for
+ * pagination of items which have the exact same updated at.
+ *
+ * Conceptually, it may happen that there are more items than the limit we've
+ * provided, but there are practical safeguards.
+ *
+ * For file diff, the limit is advisory, and remote may return less, equal or
+ * more items than the provided limit. The scenario where it returns more is
+ * when more files than the limit have the same updated at. Theoretically it
+ * would make the diff response unbounded, however in practice file
+ * modifications themselves are all batched. Even if the user were to select all
+ * the files in their library and updates them all in one go in the UI, their
+ * client app is required to use batched API calls to make those updates, and
+ * each of those batches would get distinct updated at.
+ */
+const defaultDiffLimit = 500;
+
+/**
+ * Fetch all entities of the given type that have been created or updated since
+ * the given time.
+ *
+ * For each batch of fetched entities, call a provided function that can ingest
+ * them. This function is also provided the latest timestamp from amongst all of
+ * the entities fetched so far, which the caller can persist if needed to resume
+ * future diffs from the current checkpoint.
+ */
+export const entityDiff = async () => {
+ const sinceTime = 0;
+ const type: EntityType = "person_v2";
+ const limit = defaultDiffLimit;
+ const params = new URLSearchParams({ type, sinceTime, limit });
+ // const url = await apiURL(`/user-entity/entity/diff`);
+ // const res = await fetch(`${url}?${params.toString()}`, {
+ // headers: await authenticatedRequestHeaders(),
+ // });
+ // ensureOk(res);
+ // };
+};