mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
test(pulse): prove the day-mean method across readers, the dry run's single write and the bounded heap
This commit is contained in:
1 parent
9f17cef8e4
commit
46e82efe22
5 files changed
+431
-5
No files matched your search
@@ -167,7 +167,10 @@ describe("POST dry_run", () => {
|
||||
expect(send).toHaveBeenCalledWith(
|
||||
"pulse-day-mean",
|
||||
{ action: "dry_run" },
|
||||
expect.objectContaining({ retryLimit: 0, singletonKey: "pulse-day-mean" }),
|
||||
expect.objectContaining({
|
||||
retryLimit: 0,
|
||||
singletonKey: "pulse-day-mean",
|
||||
}),
|
||||
);
|
||||
expect(prisma.appSettings.upsert).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -175,7 +175,10 @@ function windows(
|
||||
const start = Math.floor(first.getTime() / DAY_MS) * DAY_MS;
|
||||
const end = (Math.floor(last.getTime() / DAY_MS) + 1) * DAY_MS;
|
||||
for (let t = start; t < end; t += days * DAY_MS) {
|
||||
out.push({ from: new Date(t), to: new Date(Math.min(end, t + days * DAY_MS)) });
|
||||
out.push({
|
||||
from: new Date(t),
|
||||
to: new Date(Math.min(end, t + days * DAY_MS)),
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -175,8 +175,9 @@ describe("pulse day-mean method", () => {
|
||||
});
|
||||
|
||||
it("weighs hours by min(1, n / 3)", () => {
|
||||
expect([1, 2, 3, 10].map((n) => hourWeight(n, "weighted_hour_mean_v2")))
|
||||
.toEqual([1 / 3, 2 / 3, 1, 1]);
|
||||
expect(
|
||||
[1, 2, 3, 10].map((n) => hourWeight(n, "weighted_hour_mean_v2")),
|
||||
).toEqual([1 / 3, 2 / 3, 1, 1]);
|
||||
expect([1, 2, 3].map((n) => hourWeight(n, "hour_mean_v1"))).toEqual([
|
||||
1, 1, 1,
|
||||
]);
|
||||
|
||||
@@ -14,7 +14,12 @@ export const pulseDayMeanActionSchema = z.strictObject({
|
||||
export type PulseDayMeanActionInput = z.infer<typeof pulseDayMeanActionSchema>;
|
||||
|
||||
/** Where a day's change between the two methods falls, in bpm. */
|
||||
export const PULSE_DAY_MEAN_CHANGE_BUCKETS = ["0-1", "1-2", "2-5", "5+"] as const;
|
||||
export const PULSE_DAY_MEAN_CHANGE_BUCKETS = [
|
||||
"0-1",
|
||||
"1-2",
|
||||
"2-5",
|
||||
"5+",
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* What a dry run found. Accounts are numbered in the order they were created
|
||||
|
||||
Reference in new issue
Block a user