mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
Merge branch 'fix/v1437-data' into release/v1.43.7
This commit is contained in:
commit
dee6a27ae4
100 files changed
+2314
-506
No files matched your search
@@ -22,6 +22,8 @@ import {
|
||||
resolveBulkShareDocuments,
|
||||
SHARE_LINK_MAX_DOCUMENTS,
|
||||
vaultFiltersToSearch,
|
||||
STAGED_ATTACHMENT_POLL_MS,
|
||||
stagedAttachmentPollInterval,
|
||||
} from "../vault-utils";
|
||||
|
||||
function doc(overrides: Partial<InboundDocumentDto> = {}): InboundDocumentDto {
|
||||
@@ -541,3 +543,36 @@ describe("buildProcedureChoices", () => {
|
||||
expect(buildProcedureChoices([], null, labels)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("stagedAttachmentPollInterval", () => {
|
||||
const now = Date.parse("2026-10-20T10:00:00Z");
|
||||
const at = (msAgo: number) => new Date(now - msAgo).toISOString();
|
||||
|
||||
it("polls a fresh upload until its index lands", () => {
|
||||
expect(
|
||||
stagedAttachmentPollInterval(
|
||||
{ createdAt: at(30_000), hasContentIndex: false },
|
||||
now,
|
||||
),
|
||||
).toBe(STAGED_ATTACHMENT_POLL_MS);
|
||||
expect(
|
||||
stagedAttachmentPollInterval(
|
||||
{ createdAt: at(30_000), hasContentIndex: true },
|
||||
now,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("stops polling a document that is never indexed once the window passes", () => {
|
||||
expect(
|
||||
stagedAttachmentPollInterval(
|
||||
{ createdAt: at(RECENT_UPLOAD_WINDOW_MS + 1), hasContentIndex: false },
|
||||
now,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("does not poll before the detail has loaded", () => {
|
||||
expect(stagedAttachmentPollInterval(undefined, now)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -167,6 +167,26 @@ export function isDocumentProcessing(
|
||||
return !doc.hasContentIndex && isRecentlyUploaded(doc.createdAt, now);
|
||||
}
|
||||
|
||||
/**
|
||||
* How often the Coach polls a staged attachment for its content index.
|
||||
*
|
||||
* The same "still processing" question the vault list asks, so the same
|
||||
* bounded window answers it: a document that will never be indexed (an
|
||||
* unsupported format, indexing disabled) used to be polled every 2.5 s for as
|
||||
* long as the Coach stayed open. `false` once the index exists or the window
|
||||
* has passed.
|
||||
*/
|
||||
export const STAGED_ATTACHMENT_POLL_MS = 2_500;
|
||||
|
||||
export function stagedAttachmentPollInterval(
|
||||
doc: Pick<InboundDocumentDto, "createdAt" | "hasContentIndex"> | undefined,
|
||||
now: number = Date.now(),
|
||||
): number | false {
|
||||
return doc && isDocumentProcessing(doc, now)
|
||||
? STAGED_ATTACHMENT_POLL_MS
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether ANY document in the list is still inside its processing window —
|
||||
* drives the vault list query's poll-while-indexing `refetchInterval`.
|
||||
|
||||
Reference in new issue
Block a user