You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(patches): Patchy remembers what each person opens #708
The record behind Your usual and "new to you": one row per person and patch, with when they last opened it and a score that halves every 7 days since.
Migration 0017_patch_opens in packages/patches/src/migrations.ts: patch_opens (user_id, patch_id, last_opened_at, score), all non-null, primary key (user_id, patch_id), both foreign keys ON DELETE CASCADE, and an index on patch_id.
Patches.recordOpen(userId, patchId): one upsert against a serving patch, score = score · 2^(−(now − last_opened_at) / 7 days) + 1, using the service's clock.
Patches.opens(userId): the member's rows as { patchId, lastOpenedAt, score }, decayed to now.
ReadPatch gains visits (the existing visit_count).
Serving (packages/serving/src/Pages.ts) records an open when it serves the current version's address to an admitted member, beside recordVisit. Not for older version URLs, the content URL or public patches. A failure logs a warning and never denies the page.
Acceptance
Opening a company patch's address twice as one member leaves a score of 2; another member has no row.
The content URL, an older version's URL, a public patch and a signed-out request write nothing.
A failed write still serves the page.
Seven days later the score reads 1; opening it again makes 2.
Reclaiming a patch deletes its rows.
Docs
Patches glossary: Open. Serving glossary: members' opens belong to Patches. docs/product.md: next to "The host knows who opened a company page", Patchy remembers what each member opened for their own Home, and nobody else sees it.
Activity
/opens your tools instead of managing one patch #707feat(patches): Patchy remembers what each person opens