demo

package
v0.33.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package demo seeds and identifies the public read-only demo account (B7). It is PREVIEW ONLY: Enabled requires RIVOLT_DEMO=true and RIVIAN_CLIENT=replay and RIVOLT_REPLAY_SOURCE=sample, so a production install (live client) never turns it on even if the variable leaks into its environment.

Index

Constants

View Source
const (
	HomeLat   = 34.1613
	HomeLon   = -118.1676
	HomeLabel = "Rose Bowl parking (sample)"
	// HomeRate is the demo's home $/kWh, USD.
	HomeRate = 0.16
)

The demo truck's "home": the sample generator's public, non- residential stadium parking lot (never anyone's address).

View Source
const Username = "rivolt-public-demo"

Username is the demo account's username. It has no @, so it can't collide with a real (email-derived) sign-in, and nobody holds a credential for it: it is only ever reached through the anonymous, read-only allowlist.

Variables

This section is empty.

Functions

func ApplySampleUserPrices added in v0.33.0

func ApplySampleUserPrices(ctx context.Context, d *sql.DB, store pricer) (int, error)

ApplySampleUserPrices gives the demo truck's hand-priced session (the Las Vegas hotel L2, a flat $15 in the sample corpus) its user price after replay has recorded it. The recorder cannot invent a price only a person enters, so this is the demo's stand-in for that person. It uses the same store path as PATCH /charges/{id}/pricing, which stamps cost_source = user.

Only CLOSED charges with no cost source are touched: an open charge is still being upserted by the recorder, which would overwrite the price. Idempotent; returns how many rows it priced. The corpus loops, so the caller runs it again periodically.

func Enabled

func Enabled() bool

Enabled reports whether the demo is on: RIVOLT_DEMO=true on an install running the replay client over the GENERATED sample corpus (RIVOLT_REPLAY_SOURCE=sample). Replaying a recorded vehicle would publish a real person's history anonymously, so anything else fails closed.

func PriceCandidates added in v0.33.0

func PriceCandidates(ctx context.Context, cands []PriceCandidate, store pricer) (int, error)

PriceCandidates prices the candidates the sample corpus says a person priced by hand, and returns how many it priced.

func RunPricing added in v0.33.0

func RunPricing(ctx context.Context, d *sql.DB, store pricer, every time.Duration, log func(msg string, args ...any))

RunPricing applies the sample user prices now and then every interval until ctx ends (replay backfill and corpus loops bring new sessions).

func Seed

func Seed(ctx context.Context, d Deps) error

Seed creates (or refreshes) the demo user, its settings, its replay session and a few older charges. Idempotent; safe at every boot. It does nothing unless Enabled.

func SeedCharges

func SeedCharges(uid uuid.UUID, now time.Time) []charges.Charge

SeedCharges are the hand-written older sessions that complete the cost-source set (the replay stream supplies home_rate, network_estimate, the Rivian-billed DC fast and, via ApplySampleUserPrices, the user-priced hotel L2): a pending (unpriced) AC session and a home-rate home session. They sit 50-60 days back, before the 45-day replay corpus, so they never overlap a replayed session. Times are day-aligned, so reseeding is stable.

func UserID

func UserID() uuid.UUID

UserID is the demo account's user id.

func VehicleID

func VehicleID() string

VehicleID is the demo vehicle's Rivian id.

Types

type Deps

type Deps struct {
	DB       *sql.DB
	Settings *settings.Factory
	Charges  *charges.Factory
	Secrets  *secrets.Store
	Now      func() time.Time
}

Deps are what Seed writes through.

type PriceCandidate added in v0.33.0

type PriceCandidate struct {
	ID        string
	StartedAt time.Time
}

PriceCandidate is a closed, unpriced demo charge.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL