@jam-overture/loom 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/audience/compose.d.ts +112 -0
- package/dist/audience/compose.js +134 -0
- package/dist/audience/memory.d.ts +14 -0
- package/dist/audience/memory.js +71 -0
- package/dist/audience/overlay-store.d.ts +343 -0
- package/dist/audience/overlay-store.js +217 -0
- package/dist/audience/rule.d.ts +121 -0
- package/dist/audience/rule.js +78 -0
- package/dist/cli/index.d.ts +3 -4
- package/dist/cli/index.js +3 -4
- package/dist/cli/templates.js +19 -0
- package/dist/data/adapter.d.ts +9 -1
- package/dist/data/adapter.js +2 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +31 -4
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interpretation/anthropic.d.ts +1 -1
- package/dist/interpretation/anthropic.js +2 -22
- package/dist/interpretation/client.d.ts +1 -1
- package/dist/interpretation/materialize.js +67 -22
- package/dist/interpretation/openai-compatible.d.ts +36 -0
- package/dist/interpretation/openai-compatible.js +79 -0
- package/dist/interpretation/status.d.ts +19 -0
- package/dist/interpretation/status.js +26 -0
- package/dist/live/index.d.ts +73 -0
- package/dist/live/index.js +73 -0
- package/dist/live/pages.d.ts +187 -0
- package/dist/live/pages.js +161 -0
- package/dist/live/pull.d.ts +147 -0
- package/dist/live/pull.js +398 -0
- package/dist/live/pulling.d.ts +79 -0
- package/dist/live/pulling.js +117 -0
- package/dist/live/window.d.ts +129 -0
- package/dist/live/window.js +132 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/addressed.d.ts +35 -0
- package/dist/render/addressed.js +79 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/document-theme.d.ts +70 -0
- package/dist/render/document-theme.js +139 -0
- package/dist/render/editable.d.ts +15 -1
- package/dist/render/editable.js +13 -1
- package/dist/render/expected.d.ts +98 -0
- package/dist/render/expected.js +88 -0
- package/dist/render/index.d.ts +4 -0
- package/dist/render/index.js +4 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.d.ts +11 -0
- package/dist/render/render.js +294 -53
- package/dist/render/request.d.ts +8 -1
- package/dist/render/request.js +1 -0
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
- package/dist/runtime/auto-apply-ceiling.js +66 -0
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +91 -10
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/nesting.d.ts +13 -1
- package/dist/runtime/nesting.js +41 -24
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +305 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/policy.d.ts +8 -6
- package/dist/runtime/policy.js +5 -2
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +129 -5
- package/dist/sdk/definition.js +66 -0
- package/dist/sdk/registry.d.ts +45 -2
- package/dist/sdk/registry.js +102 -1
- package/dist/signals/acted.contract.d.ts +21 -0
- package/dist/signals/acted.contract.js +236 -0
- package/dist/signals/acted.d.ts +359 -0
- package/dist/signals/acted.js +135 -0
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/agenda.d.ts +585 -0
- package/dist/signals/agenda.js +295 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arrivals.contract.d.ts +21 -0
- package/dist/signals/arrivals.contract.js +180 -0
- package/dist/signals/arrivals.d.ts +375 -0
- package/dist/signals/arrivals.js +254 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +33 -17
- package/dist/signals/broadcast.js +255 -32
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +169 -34
- package/dist/signals/collect.js +186 -38
- package/dist/signals/conversion.d.ts +348 -0
- package/dist/signals/conversion.js +235 -0
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/correlated.contract.d.ts +24 -0
- package/dist/signals/correlated.contract.js +94 -0
- package/dist/signals/counters.d.ts +97 -0
- package/dist/signals/counters.js +160 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +395 -0
- package/dist/signals/deployment-change.js +309 -0
- package/dist/signals/deployment.d.ts +278 -0
- package/dist/signals/deployment.js +178 -0
- package/dist/signals/door.d.ts +114 -0
- package/dist/signals/door.js +77 -0
- package/dist/signals/expire.d.ts +192 -0
- package/dist/signals/expire.js +213 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/frontier.d.ts +268 -0
- package/dist/signals/frontier.js +145 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel-hours.contract.d.ts +21 -0
- package/dist/signals/funnel-hours.contract.js +221 -0
- package/dist/signals/funnel-hours.d.ts +293 -0
- package/dist/signals/funnel-hours.js +99 -0
- package/dist/signals/funnel.d.ts +592 -0
- package/dist/signals/funnel.js +231 -0
- package/dist/signals/health.d.ts +694 -0
- package/dist/signals/health.js +573 -0
- package/dist/signals/index.d.ts +60 -0
- package/dist/signals/index.js +60 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/inside.d.ts +190 -0
- package/dist/signals/inside.js +263 -0
- package/dist/signals/join.d.ts +56 -0
- package/dist/signals/join.js +60 -0
- package/dist/signals/journal.d.ts +123 -9
- package/dist/signals/kept.contract.d.ts +22 -0
- package/dist/signals/kept.contract.js +111 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-agenda-change.d.ts +324 -0
- package/dist/signals/library-agenda-change.js +199 -0
- package/dist/signals/library-agenda.d.ts +258 -0
- package/dist/signals/library-agenda.js +167 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +646 -0
- package/dist/signals/library-reach-change.js +542 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-senders-change.d.ts +457 -0
- package/dist/signals/library-senders-change.js +367 -0
- package/dist/signals/library-senders-reach-change.d.ts +486 -0
- package/dist/signals/library-senders-reach-change.js +538 -0
- package/dist/signals/library-senders-reach.d.ts +340 -0
- package/dist/signals/library-senders-reach.js +252 -0
- package/dist/signals/library-senders.d.ts +271 -0
- package/dist/signals/library-senders.js +180 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +564 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +246 -14
- package/dist/signals/migrate.d.ts +20 -4
- package/dist/signals/migrate.js +269 -8
- package/dist/signals/notice.d.ts +389 -0
- package/dist/signals/notice.js +250 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/part-pace.d.ts +378 -0
- package/dist/signals/part-pace.js +333 -0
- package/dist/signals/parts.d.ts +354 -0
- package/dist/signals/parts.js +232 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +753 -76
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +163 -0
- package/dist/signals/retention.js +75 -0
- package/dist/signals/rhythm.d.ts +302 -0
- package/dist/signals/rhythm.js +262 -0
- package/dist/signals/rollup.d.ts +194 -4
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +1069 -1
- package/dist/signals/schema.js +393 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +1147 -0
- package/dist/signals/silences.js +996 -0
- package/dist/signals/subtrees.d.ts +123 -0
- package/dist/signals/subtrees.js +102 -0
- package/dist/signals/tally.d.ts +262 -12
- package/dist/signals/unread.d.ts +292 -0
- package/dist/signals/unread.js +137 -0
- package/dist/signals/window-agenda.d.ts +276 -0
- package/dist/signals/window-agenda.js +83 -0
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window-funnels.d.ts +88 -0
- package/dist/signals/window-funnels.js +47 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/cache.d.ts +101 -0
- package/dist/store/cache.js +149 -0
- package/dist/store/history.d.ts +82 -0
- package/dist/store/history.js +36 -0
- package/dist/store/index.d.ts +30 -0
- package/dist/store/index.js +30 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +106 -0
- package/dist/store/migrate.js +323 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-audience.d.ts +14 -0
- package/dist/store/postgres-audience.js +272 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +17 -1
- package/dist/store/postgres.js +60 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +762 -2
- package/dist/store/schema.js +218 -5
- package/dist/store/source.d.ts +57 -1
- package/dist/store/source.js +65 -1
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.d.ts +1 -1
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/journal.d.ts +104 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +33 -1
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +188 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/telemetry/window.d.ts +135 -0
- package/dist/telemetry/window.js +101 -0
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/audience-overlay-contract.d.ts +31 -0
- package/dist/testing/audience-overlay-contract.js +354 -0
- package/dist/testing/contracts.d.ts +13 -7
- package/dist/testing/contracts.js +13 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +297 -6
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/contrast.d.ts +19 -14
- package/dist/theme/contrast.js +181 -17
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/apply.js +13 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +24 -12
- package/dist/tree/navigation.d.ts +5 -0
- package/dist/tree/navigation.js +32 -10
- package/dist/tree/outline.d.ts +7 -0
- package/dist/tree/outline.js +9 -5
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +25 -3
- package/dist/runtime/inverse-interpreter.d.ts +0 -90
- package/dist/runtime/inverse-interpreter.js +0 -56
package/dist/signals/schema.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { sql } from "drizzle-orm";
|
|
2
2
|
import { bigint, bigserial, index, integer, jsonb, pgTable, primaryKey, text, timestamp, } from "drizzle-orm/pg-core";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Six tables: the buffer batches wait in, and the five counters that outlive
|
|
5
5
|
* them.
|
|
6
6
|
*
|
|
7
7
|
* The split is 0146's — raw signals are short-lived and aggregates are durable
|
|
8
8
|
* — and it is in the schema rather than in a policy because a single table
|
|
9
9
|
* would make the retention rule a `DELETE` somebody has to remember to write
|
|
10
10
|
* correctly forever.
|
|
11
|
+
*
|
|
12
|
+
* All six carry `application_id` (0269), led by it in every key and every
|
|
13
|
+
* index, on the same terms as the store's four: a reader is filed against the
|
|
14
|
+
* application whose page they read, and no reading here spans two.
|
|
15
|
+
*
|
|
16
|
+
* All six then carry `audience_id` immediately after it
|
|
17
|
+
* ([0284](../../decisions/0284-a-signal-names-the-audience-it-was-collected-under-and-the-predicate-stays-in-the-control-plane.md)),
|
|
18
|
+
* which is the second of the two migrations
|
|
19
|
+
* [0273](../../decisions/0273-the-reader-tables-take-the-application-now-and-the-audience-when-it-is-ratified.md)
|
|
20
|
+
* chose to take rather than wait for. The two dimensions differ in kind, and
|
|
21
|
+
* the difference is why one is a handle's scope and the other is a column: no
|
|
22
|
+
* reading spans two applications, where comparing two audiences is the whole
|
|
23
|
+
* point of serving two.
|
|
11
24
|
*/
|
|
12
25
|
/**
|
|
13
26
|
* The buffer.
|
|
@@ -24,6 +37,32 @@ import { bigint, bigserial, index, integer, jsonb, pgTable, primaryKey, text, ti
|
|
|
24
37
|
*/
|
|
25
38
|
export const loomReaderSignals = pgTable("loom_reader_signals", {
|
|
26
39
|
seq: bigserial("seq", { mode: "number" }).primaryKey(),
|
|
40
|
+
/**
|
|
41
|
+
* The application the reading belongs to (0269). First in the key and in
|
|
42
|
+
* every index, as it is on the store's tables, because every read of this
|
|
43
|
+
* table is already inside one application.
|
|
44
|
+
*
|
|
45
|
+
* Defaulted so a database written before applications existed keeps
|
|
46
|
+
* answering, and so that every rollup, door and screen that names no
|
|
47
|
+
* application goes on meaning what it meant. `DEFAULT_APPLICATION_ID` is
|
|
48
|
+
* the value, spelled out because DDL cannot import it — `scoped.test.ts`
|
|
49
|
+
* holds the two together.
|
|
50
|
+
*/
|
|
51
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
52
|
+
/**
|
|
53
|
+
* The audience this batch's reader was served under (0284). Second in the
|
|
54
|
+
* key and in every index, immediately after the application.
|
|
55
|
+
*
|
|
56
|
+
* Defaulted for the same reason the application is, and to the same effect:
|
|
57
|
+
* a batch that names no audience, and every row written before the
|
|
58
|
+
* dimension existed, reads as `aud_everyone` — the audience that matches
|
|
59
|
+
* every reader. `DEFAULT_AUDIENCE_ID` is the value, spelled out because DDL
|
|
60
|
+
* cannot import it; `scoped.test.ts` holds the two together.
|
|
61
|
+
*
|
|
62
|
+
* Opaque. What an `aud_` means is the control plane's to say, and no column
|
|
63
|
+
* here holds the predicate that selected it.
|
|
64
|
+
*/
|
|
65
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
27
66
|
treeId: text("tree_id").notNull(),
|
|
28
67
|
revision: integer("revision").notNull(),
|
|
29
68
|
/** What the page said the time was, which is a number a page said. */
|
|
@@ -33,7 +72,47 @@ export const loomReaderSignals = pgTable("loom_reader_signals", {
|
|
|
33
72
|
receivedAt: timestamp("received_at", { withTimezone: true })
|
|
34
73
|
.notNull()
|
|
35
74
|
.default(sql `now()`),
|
|
36
|
-
|
|
75
|
+
/**
|
|
76
|
+
* When a fold counted this delivery into the counters (0351).
|
|
77
|
+
*
|
|
78
|
+
* Nullable and undefaulted, and null is a state rather than a gap: *not yet
|
|
79
|
+
* counted*. It is the only column on this table a second statement ever
|
|
80
|
+
* writes, and the only writer is the collection run — which is why the
|
|
81
|
+
* `UPDATE` that sets it carries `folded_at IS NULL`, so a repeat of that
|
|
82
|
+
* statement cannot move an instant a reading has been taken against.
|
|
83
|
+
*
|
|
84
|
+
* A row written before the column existed reads as uncounted, which is
|
|
85
|
+
* conservative in the one direction that matters: retention will not delete
|
|
86
|
+
* what nothing says was counted, so the first fold after the migration
|
|
87
|
+
* stamps it and the second sweep takes it.
|
|
88
|
+
*/
|
|
89
|
+
foldedAt: timestamp("folded_at", { withTimezone: true }),
|
|
90
|
+
}, (table) => [
|
|
91
|
+
/**
|
|
92
|
+
* Unchanged by the audience dimension, which is not the shape the
|
|
93
|
+
* application took (0284).
|
|
94
|
+
*
|
|
95
|
+
* The index was widened to lead with the application because every read of
|
|
96
|
+
* the buffer is inside one (0273), so it belongs in the prefix. Nothing reads the
|
|
97
|
+
* buffer by audience: a rollup folds a whole window and groups by the
|
|
98
|
+
* column, so putting the audience second here would displace `tree_id` and
|
|
99
|
+
* `seq` from the prefix and make every read that exists scan wider, to
|
|
100
|
+
* serve a filter no caller expresses.
|
|
101
|
+
*/
|
|
102
|
+
index("loom_reader_signals_tree_seq_idx").on(table.applicationId, table.treeId, table.seq),
|
|
103
|
+
/**
|
|
104
|
+
* The oldest end of the whole application, which both sweeps start from
|
|
105
|
+
* (0351).
|
|
106
|
+
*
|
|
107
|
+
* It did not exist while the table held an hour of deliveries, because a
|
|
108
|
+
* scan of an hour is cheap however it is served. The kept window makes it
|
|
109
|
+
* thirty days by default and invites a deployment to lengthen it, so the
|
|
110
|
+
* two reads that run from the oldest end across every tree — the fold's
|
|
111
|
+
* scan and retention's — are the two reads whose cost would have grown with
|
|
112
|
+
* the setting.
|
|
113
|
+
*/
|
|
114
|
+
index("loom_reader_signals_seq_idx").on(table.applicationId, table.seq),
|
|
115
|
+
]);
|
|
37
116
|
/**
|
|
38
117
|
* One node at one revision, summed.
|
|
39
118
|
*
|
|
@@ -42,6 +121,10 @@ export const loomReaderSignals = pgTable("loom_reader_signals", {
|
|
|
42
121
|
* surrogate id would mean a lookup before every one of those.
|
|
43
122
|
*/
|
|
44
123
|
export const loomReaderTallies = pgTable("loom_reader_tallies", {
|
|
124
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
125
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
126
|
+
/** See `loomReaderSignals.audienceId`. In the key here, unlike the buffer's. */
|
|
127
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
45
128
|
treeId: text("tree_id").notNull(),
|
|
46
129
|
revision: integer("revision").notNull(),
|
|
47
130
|
nodeId: text("node_id").notNull(),
|
|
@@ -58,8 +141,24 @@ export const loomReaderTallies = pgTable("loom_reader_tallies", {
|
|
|
58
141
|
activations: bigint("activations", { mode: "number" }).notNull(),
|
|
59
142
|
opens: bigint("opens", { mode: "number" }).notNull(),
|
|
60
143
|
closes: bigint("closes", { mode: "number" }).notNull(),
|
|
144
|
+
/**
|
|
145
|
+
* Added with the fifth kind, and defaulted for the same reason `engaged`
|
|
146
|
+
* is: a deployment whose table predates the question has rows for which
|
|
147
|
+
* `0` is the true answer, not a missing one.
|
|
148
|
+
*/
|
|
149
|
+
completions: bigint("completions", { mode: "number" }).notNull().default(0),
|
|
61
150
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
62
|
-
}, (table) => [
|
|
151
|
+
}, (table) => [
|
|
152
|
+
primaryKey({
|
|
153
|
+
columns: [
|
|
154
|
+
table.applicationId,
|
|
155
|
+
table.audienceId,
|
|
156
|
+
table.treeId,
|
|
157
|
+
table.revision,
|
|
158
|
+
table.nodeId,
|
|
159
|
+
],
|
|
160
|
+
}),
|
|
161
|
+
]);
|
|
63
162
|
/**
|
|
64
163
|
* One funnel pair at one revision.
|
|
65
164
|
*
|
|
@@ -68,25 +167,316 @@ export const loomReaderTallies = pgTable("loom_reader_tallies", {
|
|
|
68
167
|
* has instead of orphaning them.
|
|
69
168
|
*/
|
|
70
169
|
export const loomReaderFunnels = pgTable("loom_reader_funnels", {
|
|
170
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
171
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
172
|
+
/** See `loomReaderSignals.audienceId`. In the key here, unlike the buffer's. */
|
|
173
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
174
|
+
treeId: text("tree_id").notNull(),
|
|
175
|
+
revision: integer("revision").notNull(),
|
|
176
|
+
fromNodeId: text("from_node_id").notNull(),
|
|
177
|
+
fromKind: text("from_kind").notNull(),
|
|
178
|
+
toNodeId: text("to_node_id").notNull(),
|
|
179
|
+
toKind: text("to_kind").notNull(),
|
|
180
|
+
reached: bigint("reached", { mode: "number" }).notNull(),
|
|
181
|
+
converted: bigint("converted", { mode: "number" }).notNull(),
|
|
182
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
183
|
+
}, (table) => [
|
|
184
|
+
primaryKey({
|
|
185
|
+
columns: [
|
|
186
|
+
table.applicationId,
|
|
187
|
+
table.audienceId,
|
|
188
|
+
table.treeId,
|
|
189
|
+
table.revision,
|
|
190
|
+
table.fromNodeId,
|
|
191
|
+
table.fromKind,
|
|
192
|
+
table.toNodeId,
|
|
193
|
+
table.toKind,
|
|
194
|
+
],
|
|
195
|
+
}),
|
|
196
|
+
]);
|
|
197
|
+
/**
|
|
198
|
+
* One region at one revision, as page views that began there.
|
|
199
|
+
*
|
|
200
|
+
* The narrowest table in the subsystem, and the narrowness is the point: a tree,
|
|
201
|
+
* a revision, a country and a number. There is no view key, no address, no
|
|
202
|
+
* digest of one and no per-arrival row, so there is nothing here to join against
|
|
203
|
+
* — which is what makes a region safe to keep for as long as the counters it
|
|
204
|
+
* sits beside.
|
|
205
|
+
*
|
|
206
|
+
* Written on the request path rather than by a rollup, because the request is
|
|
207
|
+
* the only place the region was ever knowable, and `views` counts openings so
|
|
208
|
+
* that a long visit is not a large number.
|
|
209
|
+
*/
|
|
210
|
+
export const loomReaderRegions = pgTable("loom_reader_regions", {
|
|
211
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
212
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
213
|
+
/** See `loomReaderSignals.audienceId`. In the key here, unlike the buffer's. */
|
|
214
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
215
|
+
treeId: text("tree_id").notNull(),
|
|
216
|
+
revision: integer("revision").notNull(),
|
|
217
|
+
/** A country code, or the word for not knowing. A closed set, so this column cannot be written freely. */
|
|
218
|
+
region: text("region").notNull(),
|
|
219
|
+
views: bigint("views", { mode: "number" }).notNull(),
|
|
220
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
221
|
+
}, (table) => [primaryKey({
|
|
222
|
+
columns: [table.applicationId, table.audienceId, table.treeId, table.revision, table.region],
|
|
223
|
+
})]);
|
|
224
|
+
/**
|
|
225
|
+
* One revision's page views, counted from both ends.
|
|
226
|
+
*
|
|
227
|
+
* Two columns rather than two tables, because they are two counts of the same
|
|
228
|
+
* page views and the only question anybody asks of them is their difference:
|
|
229
|
+
* `opened` is written at the door, once per page view that began, and
|
|
230
|
+
* `appearances` by each rollup that saw that page view in its window. Keeping
|
|
231
|
+
* them in one row makes the subtraction a column expression instead of a join,
|
|
232
|
+
* and makes it impossible for a reading to find one and not the other.
|
|
233
|
+
*
|
|
234
|
+
* Both default to nought because either side may create the row, and nought is
|
|
235
|
+
* the true answer for the column that has not been written yet rather than a
|
|
236
|
+
* missing one.
|
|
237
|
+
*
|
|
238
|
+
* As narrow as the regions table and for the same reason: a tree, a revision
|
|
239
|
+
* and two numbers. No view key, no region, nothing per arrival, nothing to join.
|
|
240
|
+
*/
|
|
241
|
+
export const loomReaderPageViews = pgTable("loom_reader_page_views", {
|
|
242
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
243
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
244
|
+
/** See `loomReaderSignals.audienceId`. In the key here, unlike the buffer's. */
|
|
245
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
246
|
+
treeId: text("tree_id").notNull(),
|
|
247
|
+
revision: integer("revision").notNull(),
|
|
248
|
+
/** Page views that began. Counted once, at the door, never recounted. */
|
|
249
|
+
opened: bigint("opened", { mode: "number" }).notNull().default(0),
|
|
250
|
+
/** The same page views, once per rollup window each appeared in (0147). */
|
|
251
|
+
appearances: bigint("appearances", { mode: "number" }).notNull().default(0),
|
|
252
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
253
|
+
/**
|
|
254
|
+
* When a rollup last folded a window holding page views of this revision.
|
|
255
|
+
*
|
|
256
|
+
* The one column in this subsystem written by exactly one of a row's two
|
|
257
|
+
* writers, and that is its whole purpose: `updated_at` moves on every
|
|
258
|
+
* delivery the door counts *and* on every fold, so a deployment whose
|
|
259
|
+
* rollup has stopped keeps a fresh timestamp on a row whose appearances
|
|
260
|
+
* never move again. This one moves only when something folded.
|
|
261
|
+
*
|
|
262
|
+
* Nullable and undefaulted, which is the honest value for a row nothing
|
|
263
|
+
* has folded yet and for a row written before this column existed — those
|
|
264
|
+
* two are the same state, *nothing attests a fold*, and no fault is raised
|
|
265
|
+
* from it.
|
|
266
|
+
*/
|
|
267
|
+
foldedAt: timestamp("folded_at", { withTimezone: true }),
|
|
268
|
+
}, (table) => [
|
|
269
|
+
primaryKey({
|
|
270
|
+
columns: [table.applicationId, table.audienceId, table.treeId, table.revision],
|
|
271
|
+
}),
|
|
272
|
+
]);
|
|
273
|
+
/**
|
|
274
|
+
* Page views that began, by the hour they began in.
|
|
275
|
+
*
|
|
276
|
+
* **The sixth table, and the first in this subsystem with a clock in its
|
|
277
|
+
* key** — the seventh, what readers did by hour, is the other. Everything else
|
|
278
|
+
* here is either timeless — a tally, a funnel answer, a
|
|
279
|
+
* region bucket and a page-view total say *so far* and nothing about when — or
|
|
280
|
+
* short-lived, which is the buffer. `docs/portal-wireframes.md` asks for a
|
|
281
|
+
* range picker and a chart of page views by hour, and neither is answerable
|
|
282
|
+
* from a counter with no time in it or from a capped scan of the deliveries
|
|
283
|
+
* (`arrivals.ts`, which says why at length).
|
|
284
|
+
*
|
|
285
|
+
* It is written by the door, in the same transaction as the page-view total it
|
|
286
|
+
* slices, from the same openings — so the hours of a revision sum to its
|
|
287
|
+
* `opened` for every arrival counted after this table existed, and the two can
|
|
288
|
+
* never disagree about how many readers arrived.
|
|
289
|
+
*
|
|
290
|
+
* Keyed like every other counter — the application, the audience, the tree and
|
|
291
|
+
* the revision — with the hour last, so a reading for one page is a prefix scan
|
|
292
|
+
* and a reading for the deployment is the second index below.
|
|
293
|
+
*/
|
|
294
|
+
export const loomReaderArrivals = pgTable("loom_reader_arrivals", {
|
|
295
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
296
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
297
|
+
/** See `loomReaderSignals.audienceId`. In the key here, as it is on the other counters. */
|
|
298
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
299
|
+
treeId: text("tree_id").notNull(),
|
|
300
|
+
revision: integer("revision").notNull(),
|
|
301
|
+
/**
|
|
302
|
+
* The hour, as the instant it began, in UTC.
|
|
303
|
+
*
|
|
304
|
+
* A `timestamptz` rather than a number of hours since an epoch, so that a
|
|
305
|
+
* range is a `BETWEEN` an operator can read and a bucket is an instant
|
|
306
|
+
* every other column in this schema is comparable with. The truncation is
|
|
307
|
+
* the writer's, not the column's: nothing here constrains it to the hour,
|
|
308
|
+
* and `arrivals.ts` is the one place the unit is decided.
|
|
309
|
+
*/
|
|
310
|
+
hour: timestamp("hour", { withTimezone: true }).notNull(),
|
|
311
|
+
/** Page views that began in this hour. Counted once, at the door, never recounted. */
|
|
312
|
+
views: bigint("views", { mode: "number" }).notNull(),
|
|
313
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
314
|
+
}, (table) => [
|
|
315
|
+
primaryKey({
|
|
316
|
+
columns: [table.applicationId, table.audienceId, table.treeId, table.revision, table.hour],
|
|
317
|
+
}),
|
|
318
|
+
/**
|
|
319
|
+
* Every tree of one application, by hour, which is the deployment-wide
|
|
320
|
+
* chart and the only read here whose cost grows with the range.
|
|
321
|
+
*
|
|
322
|
+
* The primary key serves a reading of one page, because that read names the
|
|
323
|
+
* tree and the revision; a reading over the whole deployment names neither,
|
|
324
|
+
* and without this it would scan every row of every page to find a month.
|
|
325
|
+
*/
|
|
326
|
+
index("loom_reader_arrivals_hour_idx").on(table.applicationId, table.hour),
|
|
327
|
+
]);
|
|
328
|
+
/**
|
|
329
|
+
* What readers did to a part, by the hour they did it in.
|
|
330
|
+
*
|
|
331
|
+
* **The seventh table, and the second with a clock in its key.** Page views by
|
|
332
|
+
* hour (0356) let the portal draw a range picker and one chart; every other
|
|
333
|
+
* question on that screen — a goal's figure for the range, each goal's trend,
|
|
334
|
+
* the `By page` drawer's bars for what readers did — needs the *parts* counted
|
|
335
|
+
* by hour, and a tally keeps no time (`acted.ts`, which says why at length).
|
|
336
|
+
*
|
|
337
|
+
* **It holds the three delegated kinds and no others**, which is the whole of
|
|
338
|
+
* what keeps it affordable: `activations`, `opens`, `closes` and `completions`
|
|
339
|
+
* are things a reader aimed at something to cause (0167), so a row exists only
|
|
340
|
+
* where a reader did something. The distinct counters are not here because
|
|
341
|
+
* distinctness does not add across hours and the honest hourly denominator is
|
|
342
|
+
* the door's own arrivals; `dwell_ms` is not here because a `dwelled` signal is
|
|
343
|
+
* observed for every part that comes into view, so slicing it by hour would be
|
|
344
|
+
* thousands of rows an hour on one large page, for ever, in a table nothing
|
|
345
|
+
* sweeps.
|
|
346
|
+
*
|
|
347
|
+
* It is written by the fold, in the same transaction as the tallies it slices
|
|
348
|
+
* and from the same pass over the window — so a part's hours sum to the part's
|
|
349
|
+
* own counters for every window folded since this table existed.
|
|
350
|
+
*
|
|
351
|
+
* Keyed like the tallies with the hour last, so a reading of one part over a
|
|
352
|
+
* range is a prefix scan.
|
|
353
|
+
*/
|
|
354
|
+
export const loomReaderActedHours = pgTable("loom_reader_acted_hours", {
|
|
355
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
356
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
357
|
+
/** See `loomReaderSignals.audienceId`. In the key here, as it is on the other counters. */
|
|
358
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
359
|
+
treeId: text("tree_id").notNull(),
|
|
360
|
+
revision: integer("revision").notNull(),
|
|
361
|
+
nodeId: text("node_id").notNull(),
|
|
362
|
+
/**
|
|
363
|
+
* The hour, as the instant it began, in UTC — a `timestamptz` for the
|
|
364
|
+
* reasons `loomReaderArrivals.hour` gives, and truncated by the writer
|
|
365
|
+
* rather than by the column, because `arrivals.ts` is the one place the
|
|
366
|
+
* unit is decided.
|
|
367
|
+
*/
|
|
368
|
+
hour: timestamp("hour", { withTimezone: true }).notNull(),
|
|
369
|
+
/** What the part is, as the latest signal about it said. Not in the key, as on a tally. */
|
|
370
|
+
type: text("type").notNull(),
|
|
371
|
+
activations: bigint("activations", { mode: "number" }).notNull().default(0),
|
|
372
|
+
opens: bigint("opens", { mode: "number" }).notNull().default(0),
|
|
373
|
+
closes: bigint("closes", { mode: "number" }).notNull().default(0),
|
|
374
|
+
completions: bigint("completions", { mode: "number" }).notNull().default(0),
|
|
375
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
376
|
+
}, (table) => [
|
|
377
|
+
primaryKey({
|
|
378
|
+
columns: [
|
|
379
|
+
table.applicationId,
|
|
380
|
+
table.audienceId,
|
|
381
|
+
table.treeId,
|
|
382
|
+
table.revision,
|
|
383
|
+
table.nodeId,
|
|
384
|
+
table.hour,
|
|
385
|
+
],
|
|
386
|
+
}),
|
|
387
|
+
/**
|
|
388
|
+
* **One part of one page over a range**, which is a goal's series and the
|
|
389
|
+
* commonest read here.
|
|
390
|
+
*
|
|
391
|
+
* The primary key cannot serve it: a goal sums every revision a part has
|
|
392
|
+
* had and reads every audience unless it is comparing two, so a read naming
|
|
393
|
+
* the tree and the part names neither of the two columns that sit between
|
|
394
|
+
* them in the key.
|
|
395
|
+
*/
|
|
396
|
+
index("loom_reader_acted_part_idx").on(table.applicationId, table.treeId, table.nodeId, table.hour),
|
|
397
|
+
/**
|
|
398
|
+
* **Every part of one application, by hour**, which is the deployment-wide
|
|
399
|
+
* reading and the only one here whose cost grows with the range.
|
|
400
|
+
*/
|
|
401
|
+
index("loom_reader_acted_hour_idx").on(table.applicationId, table.hour),
|
|
402
|
+
]);
|
|
403
|
+
/**
|
|
404
|
+
* A funnel pair's answer, by the hour the readers in it entered the funnel.
|
|
405
|
+
*
|
|
406
|
+
* **The eighth table and the third with a clock in its key.** The funnel row
|
|
407
|
+
* beside it is a revision and two ends summed over every window that revision
|
|
408
|
+
* was folded in, which answers *the share since this step was set* (0418) and
|
|
409
|
+
* cannot answer *the share over these fourteen days* — the two sides a change
|
|
410
|
+
* is scored over (0402 clause 6), which is what `Page history` needs and had to
|
|
411
|
+
* read off the kept deliveries instead.
|
|
412
|
+
*
|
|
413
|
+
* The two ends are four columns rather than a reference to a configured pair,
|
|
414
|
+
* for the reason the funnel table's are: a deployment that stops asking a
|
|
415
|
+
* question keeps the answers it already has.
|
|
416
|
+
*
|
|
417
|
+
* **Both counters are distinct counts of page views, which is a thing an
|
|
418
|
+
* hourly table may hold exactly once**: a view is filed under the single hour
|
|
419
|
+
* it first reached the pair's first end in, so the hours of a window partition
|
|
420
|
+
* that window's answer instead of being filed once per delivery
|
|
421
|
+
* (`funnel-hours.ts`, which says why at length). It is written by the fold, in
|
|
422
|
+
* the same transaction as the answers it slices and from the same pass over the
|
|
423
|
+
* window, so a pair's hours sum to the pair's own row.
|
|
424
|
+
*
|
|
425
|
+
* Keyed like the funnel table with the hour last, so a reading of one pair over
|
|
426
|
+
* a range is a prefix scan.
|
|
427
|
+
*/
|
|
428
|
+
export const loomReaderFunnelHours = pgTable("loom_reader_funnel_hours", {
|
|
429
|
+
/** See `loomReaderSignals.applicationId`. */
|
|
430
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
431
|
+
/** See `loomReaderSignals.audienceId`. In the key here, as it is on the other counters. */
|
|
432
|
+
audienceId: text("audience_id").notNull().default("aud_everyone"),
|
|
71
433
|
treeId: text("tree_id").notNull(),
|
|
72
434
|
revision: integer("revision").notNull(),
|
|
73
435
|
fromNodeId: text("from_node_id").notNull(),
|
|
74
436
|
fromKind: text("from_kind").notNull(),
|
|
75
437
|
toNodeId: text("to_node_id").notNull(),
|
|
76
438
|
toKind: text("to_kind").notNull(),
|
|
439
|
+
/**
|
|
440
|
+
* The hour the readers in this row entered the funnel, as the instant it
|
|
441
|
+
* began, in UTC — a `timestamptz` for the reasons
|
|
442
|
+
* `loomReaderArrivals.hour` gives, and truncated by the writer rather than
|
|
443
|
+
* by the column.
|
|
444
|
+
*/
|
|
445
|
+
hour: timestamp("hour", { withTimezone: true }).notNull(),
|
|
446
|
+
/** Views that satisfied the first end in this hour. */
|
|
77
447
|
reached: bigint("reached", { mode: "number" }).notNull(),
|
|
448
|
+
/** Of those, the ones that satisfied the second — whenever they did it. */
|
|
78
449
|
converted: bigint("converted", { mode: "number" }).notNull(),
|
|
79
450
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
80
451
|
}, (table) => [
|
|
81
452
|
primaryKey({
|
|
82
453
|
columns: [
|
|
454
|
+
table.applicationId,
|
|
455
|
+
table.audienceId,
|
|
83
456
|
table.treeId,
|
|
84
457
|
table.revision,
|
|
85
458
|
table.fromNodeId,
|
|
86
459
|
table.fromKind,
|
|
87
460
|
table.toNodeId,
|
|
88
461
|
table.toKind,
|
|
462
|
+
table.hour,
|
|
89
463
|
],
|
|
90
464
|
}),
|
|
465
|
+
/**
|
|
466
|
+
* **One pair of one page over a range**, which is a step's two sides and
|
|
467
|
+
* the commonest read here.
|
|
468
|
+
*
|
|
469
|
+
* The primary key cannot serve it: a step sums every revision the pair has
|
|
470
|
+
* been asked of — which is the whole point of comparing two fortnights
|
|
471
|
+
* across a change — and reads every audience unless it is comparing two,
|
|
472
|
+
* so a read naming the tree and the two ends names neither of the columns
|
|
473
|
+
* that sit between them in the key.
|
|
474
|
+
*/
|
|
475
|
+
index("loom_reader_funnel_hours_pair_idx").on(table.applicationId, table.treeId, table.fromNodeId, table.toNodeId, table.hour),
|
|
476
|
+
/**
|
|
477
|
+
* **Every pair of one application, by hour**, which is the deployment-wide
|
|
478
|
+
* reading and the only one here whose cost grows with the range.
|
|
479
|
+
*/
|
|
480
|
+
index("loom_reader_funnel_hours_hour_idx").on(table.applicationId, table.hour),
|
|
91
481
|
]);
|
|
92
482
|
//# sourceMappingURL=schema.js.map
|