Use the one-shot collection commands to test dispatch and worker behavior without editing the
production schedules in configure.swift.
Start the complete local stack:
just stackThe one-shot command dispatches jobs to the metrics queue. The persistent insights-queues
worker then executes them.
%%{init: {"theme":"base","themeVariables":{"primaryColor":"#DBEAFE","primaryTextColor":"#172554","primaryBorderColor":"#2563EB","secondaryColor":"#DCFCE7","secondaryTextColor":"#14532D","secondaryBorderColor":"#16A34A","tertiaryColor":"#F3E8FF","tertiaryTextColor":"#581C87","tertiaryBorderColor":"#9333EA","lineColor":"#64748B","noteBkgColor":"#FEF3C7","noteTextColor":"#78350F","actorBkg":"#E0E7FF","actorBorder":"#4F46E5","actorTextColor":"#1E1B4B","signalColor":"#475569","signalTextColor":"#334155"}}}%%
sequenceDiagram
participant U as just command
participant C as One-shot command container
participant DB as PostgreSQL
participant Q as Valkey metrics queue
participant W as insights-queues worker
participant API as Platform API
U->>C: collect-now / collect-all-now
C->>DB: Find resources due now
C->>Q: Dispatch typed jobs
C->>DB: Advance nextCollectionAt
C-->>U: Exit successfully
W->>Q: Claim each job
W->>API: Fetch metrics
W->>DB: Store snapshots and watermark folds
| Command | What it selects | Database effect | Typical use |
|---|---|---|---|
just collect-now |
Only resources already satisfying nextCollectionAt <= now |
Advances each successfully dispatched resource by collectionIntervalDays |
Exercise the normal due-resource path |
just collect-all-now |
Every active resource | Sets every active resource due, dispatches it, then advances its next date | Force a complete local resource sweep |
just collect-accounts-now |
Every GitHub account | No resource due-date changes | Test the monthly follower collection immediately |
These commands use temporary Apple containers and remove them after dispatch completes. They
load secret-provider credentials from .env, local service settings from .env.container, and connect to
the already-running local PostgreSQL and Valkey containers.
just collect-nowThis is the safest production-like test. It may dispatch zero jobs when every resource has a
future nextCollectionAt.
just collect-all-nowThis intentionally changes local scheduling state. Each active resource is first marked due; after successful dispatch, its next date is recalculated from the current time. Do not use this against a production database unless resetting every resource's cadence is intentional.
The command follows the normal platform routing table. GitHub and Hugging Face are active; GHCR, npm, and PyPI remain outside the active dispatch routes.
just collect-accounts-nowThis dispatches SyncGitHubOrgStats for every GitHub account once. The monthly schedule remains
unchanged, so there is nothing to restore afterward. Avoid repeatedly invoking it
because all jobs consume the same provider API allowance.
The one-shot command exits after dispatching. Follow the persistent metrics worker to observe the actual API calls and writes:
container logs -f insights-queuesUseful supporting checks:
container list
container logs -n 100 insights-queues
container logs -n 50 insights-scheduled
container exec insights-valkey valkey-cli pingInspect collection dates in the local database:
container exec insights-db psql \
-U vapor_username -d vapor_database \
-c 'SELECT name, next_collection_at, collection_interval_days FROM resources ORDER BY name;'Inspect metric watermarks:
container exec insights-db psql \
-U vapor_username -d vapor_database \
-c 'SELECT resource_id, type, counted_through FROM metric_watermarks ORDER BY counted_through DESC;'All three commands use the same sync jobs as scheduled collection. GitHub clone and view jobs
therefore still call Metric.foldDailyIntoAllTime:
- completed days at or before
countedThroughare skipped; - the current incomplete UTC day is skipped;
- newly completed days advance the watermark;
- the PostgreSQL advisory lock protects concurrent folds for the same resource and metric.
Forcing a resource due changes when it is fetched, not which days have already been counted. See watermarks.md for the full explanation.
When running the application natively against local PostgreSQL and Valkey:
swift run Insights collect-resources
swift run Insights collect-resources --force
swift run Insights collect-accountsWith Docker Compose, run the same application commands through the built image and shared
environment/network. A convenient future addition is dedicated one-shot Compose services,
mirroring the existing migrate service. Until those are added, use docker compose run with
the app service and override its command according to your Compose version.
Run just collect-all-now, or inspect next_collection_at. collect-now deliberately selects
only due rows.
Check that insights-queues is running, then read its logs. The one-shot container only enqueues;
the persistent worker performs the sync.
Check Queue+SyncDispatch.swift and the current matrix in
queue-workers.md. A runnable job needs both registration and dispatch
routing.
That can be correct. When a repeated rolling window contains no completed days newer than its watermark, the stored total is already current.
#icicle-insights# #testing# #data-collection# #queues# #developer-documentation#