GoodAnalytics.Core.Events.DeviceBackfill (GoodAnalytics v0.1.1)

Copy Markdown View Source

Runtime API for backfilling event-grain device columns from stored user agents.

This module is safe to call from compiled application code, releases, remote consoles, or local maintenance tooling. It intentionally does not depend on Mix so deployed environments can run the backfill directly.

Summary

Functions

Backfills all remaining events in batches.

Backfills one batch of events.

Types

cursor()

@type cursor() :: %{id: Ecto.UUID.t(), inserted_at: DateTime.t()}

Functions

run(opts \\ [])

@spec run(keyword()) :: {:ok, non_neg_integer()}

Backfills all remaining events in batches.

Options:

  • :batch_size - maximum rows to process per batch. Defaults to 5000.

Returns {:ok, total_updated} after all currently eligible rows have been processed. Eligible rows have device_type IS NULL and a non-NULL user_agent.

run_batch(opts \\ [])

@spec run_batch(keyword()) :: {:updated, non_neg_integer(), cursor()} | {:done, 0}

Backfills one batch of events.

Returns {:updated, count, cursor} when rows were updated, or {:done, 0} when no eligible rows remain.