Leave the overnight gap out of the Timing panel
This commit is contained in:
1 parent
15211e32b0
commit
50947d077f
3 files changed
+22
-9
No files matched your search
+20
-8
@@ -1041,13 +1041,18 @@
|
||||
// "longest" figure far worse than the sparse day this feature exists to
|
||||
// take out of the numbers.
|
||||
if (spansExcluded(times[i - 1], times[i])) continue;
|
||||
// The gap from a day's last event to the next day's first is the night,
|
||||
// not how often he needs to go: it measures bedtime and a lie-in, and at
|
||||
// eight-plus hours a night it made "longest" a sleep figure and pulled
|
||||
// the typical gap up with it. Only gaps within one day are counted.
|
||||
if (ymd(new Date(times[i - 1])) !== ymd(new Date(times[i]))) continue;
|
||||
gaps.push(times[i] - times[i - 1]);
|
||||
}
|
||||
return gaps.sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
// Median is used for the "typical" gap because it ignores the single long
|
||||
// overnight gap each day, so it reflects real daytime frequency.
|
||||
// Median is used for the "typical" gap so that a single unusually long
|
||||
// stretch — a long nap, a day out — doesn't drag it the way a mean would.
|
||||
function median(sorted) {
|
||||
if (sorted.length === 0) return null;
|
||||
const mid = Math.floor(sorted.length / 2);
|
||||
@@ -1072,11 +1077,11 @@
|
||||
if (!svg || !note) continue;
|
||||
const gaps = gapsBetween(events, row.type);
|
||||
const last = lastEventOfType(events, row.type);
|
||||
drawTimingChart(svg, note, row, gaps, last ? Math.max(0, Date.now() - last.at) : null);
|
||||
drawTimingChart(svg, note, row, gaps, last ? Math.max(0, Date.now() - last.at) : null, events);
|
||||
}
|
||||
}
|
||||
|
||||
function drawTimingChart(svg, note, row, gaps, since) {
|
||||
function drawTimingChart(svg, note, row, gaps, since, events) {
|
||||
const typical = median(gaps);
|
||||
const shortest = gaps[0] ?? null;
|
||||
const longest = gaps[gaps.length - 1] ?? null;
|
||||
@@ -1087,8 +1092,15 @@
|
||||
svg.innerHTML = "";
|
||||
svg.style.display = "none";
|
||||
note.hidden = false;
|
||||
// Several logged but none sharing a day (one meal a day, say) is a
|
||||
// different case from one logged: every gap there was overnight.
|
||||
const cutoff = startOfDay(new Date());
|
||||
cutoff.setDate(cutoff.getDate() - (chartDays() - 1));
|
||||
const inWindow = events.filter(e => e.type === row.type && e.at >= cutoff.getTime()).length;
|
||||
note.textContent = since == null
|
||||
? `No ${row.noun}s logged in the last ${chartDays()} days.`
|
||||
: inWindow >= 2
|
||||
? `No two ${row.noun}s on the same day in the last ${chartDays()} days — the gap overnight isn't counted, so there is nothing to measure yet.`
|
||||
: `One ${row.noun} logged, ${formatDuration(since)} ago — log another to see the typical gap.`;
|
||||
return;
|
||||
}
|
||||
@@ -1099,10 +1111,10 @@
|
||||
const innerW = W - ML - MR;
|
||||
const trackY = 20, trackH = 8;
|
||||
|
||||
// Gaps are heavily skewed: one long overnight gap a night sits alongside
|
||||
// daytime gaps a tenth its length, and on a plain linear axis it squashes
|
||||
// the everyday range — the part you actually read — into the first tenth of
|
||||
// the track. So the axis is stretched, the way the sleep trend's is above
|
||||
// Gaps are skewed: the odd long stretch (a long nap, an afternoon out) sits
|
||||
// alongside everyday gaps a fraction its length, and on a plain linear axis
|
||||
// it squashes the everyday range — the part you actually read — into the
|
||||
// first stretch of the track. So the axis is stretched, the way the sleep trend's is above
|
||||
// 10h: the typical gap is pinned to the middle, the shortest-to-typical
|
||||
// stretch gets the left half and typical-to-longest the right. Reading it
|
||||
// is then the same in every row — left of centre is sooner than usual,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
{ "date": "2026-09-29", "text": "The Timing panel no longer counts the night. The gap from each day's last pee, poo or meal to the next morning's first was being measured like any other, so every window held several eight-hour-plus “gaps” that were really just bedtime — the longest figure was a sleep figure and the typical gap was pulled up with it. Only gaps within a single day are measured now, so the bars show how often he needs to go out while he's up and about. The “since the last one” marker is unchanged, so first thing in the morning it still reads as overdue — which, before the first trip out, it is" },
|
||||
{ "date": "2026-09-26", "text": "Tapping the tab you are already on scrolls back to the top of the page, the way it does in most phone apps — handy after scrolling a long way down Habits or the history. Switching to a different tab still leaves you where you were, as before" },
|
||||
{ "date": "2026-09-24", "text": "Kinds of food are now created in one place only — Settings → Food kinds. The Ate dialog no longer has a box for inventing one on the spot; it still lets you pick from the kinds you have, exactly as before. Making them mid-meal put a bit of list-keeping in the middle of logging, where the thing you actually came to do is record that the dog ate, and a kind typed in a hurry is easy to get slightly wrong — nothing stops two near-identical kinds existing, and clearing one up afterwards means relabelling every meal logged under it first" },
|
||||
{ "date": "2026-09-22", "text": "Habits has a Meals log beside the Food (grams) chart: every meal you have logged, newest first, across every day rather than just the one you are looking at. It is there because a meal's amount and its kind are both optional — which is what makes them easy to lose track of. A meal with no kind sits in the grey band on the chart, a meal with no amount is quietly left out of it, and until now there was nowhere to go and see which ones those were. The filter chips carry their own counts, so “No kind 412” tells you the size of the gap before you tap anything, and picking a filter lists exactly those meals; tap any row to fill in what it is missing, in the same edit dialog as everywhere else. If you started using food kinds after months of logging, the “No kind” filter also offers to label the whole list at once: choose a kind and it sets it on every meal shown. Tick “Only before” a date first if you switched foods partway, so the older meals take one kind and the newer ones keep what they have — worth getting right, because there is no undo. The panel folds away by tapping its heading like any other, and appears only once you have logged a meal; the “No kind” filter and the bulk label appear only once you have created a kind, so nothing changes for anyone not using them. A guest can see the list but cannot relabel your meals" },
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@
|
||||
</div>
|
||||
<!-- The axis is stretched (see drawTimingChart), so say what the middle
|
||||
of a bar means rather than leave it to be inferred. -->
|
||||
<p class="muted-note">The middle of every bar is that type's typical gap: left of it is sooner than usual, right of it is longer, and the faded stretch runs out to the longest gap in the window.</p>
|
||||
<p class="muted-note">The middle of every bar is that type's typical gap: left of it is sooner than usual, right of it is longer, and the faded stretch runs out to the longest gap in the window. The gap overnight, from each day's last to the next day's first, isn't counted.</p>
|
||||
</section>
|
||||
|
||||
<!-- One panel for the three views of the same events: how many a day,
|
||||
|
||||
Reference in new issue
Block a user