fix(7735): the read-already backfill touches only the rows the readers count
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Successful in 2m1s
CI & Build / integration (push) Successful in 2m8s
CI & Build / Build & push image (push) Successful in 17s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Successful in 2m1s
CI & Build / integration (push) Successful in 2m8s
CI & Build / Build & push image (push) Successful in 17s
Rows without a plugin version are skipped by every open-rate reader and are most of the table, so the correlated lookup runs on the rows recorded since 0133 only. Keeps the migration cheap on the live table, not just in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,12 @@ is stamped opened as it is written (`rule_deliveries._read_already`). This
|
|||||||
stamps the deliveries already recorded the same way, so the open rates, the
|
stamps the deliveries already recorded the same way, so the open rates, the
|
||||||
adherence readout and the weighing pass read one definition across old and
|
adherence readout and the weighing pass read one definition across old and
|
||||||
new rows: a rule read early in a session is not counted unread each time it
|
new rows: a rule read early in a session is not counted unread each time it
|
||||||
arrives again. The stamp is the delivery's own time. Not reversible: the
|
arrives again. The stamp is the delivery's own time. Only rows that carry a
|
||||||
downgrade leaves the stamps, which the earlier code reads as ordinary opens.
|
plugin version are touched: every reader skips the others
|
||||||
|
(`rule_deliveries.REPORTS_OPENS`), and they are most of the table, so the
|
||||||
|
lookup runs on the few rows recorded since 0133 rather than on all of them.
|
||||||
|
Not reversible: the downgrade leaves the stamps, which the earlier code reads
|
||||||
|
as ordinary opens.
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
@@ -26,6 +30,7 @@ def upgrade() -> None:
|
|||||||
UPDATE rule_deliveries d
|
UPDATE rule_deliveries d
|
||||||
SET opened_at = d.delivered_at
|
SET opened_at = d.delivered_at
|
||||||
WHERE d.opened_at IS NULL
|
WHERE d.opened_at IS NULL
|
||||||
|
AND d.plugin IS NOT NULL
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
SELECT 1 FROM rule_deliveries e
|
SELECT 1 FROM rule_deliveries e
|
||||||
WHERE e.user_id = d.user_id
|
WHERE e.user_id = d.user_id
|
||||||
|
|||||||
Reference in New Issue
Block a user