seeddata

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package seeddata populates an empty, migrated okpos database with a large, internally-consistent set of fake demo data: two businesses (a retail minimarket and a coffee shop) with realistic historical orders, inventory movement, and expenses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Business

type Business struct {
	Company  *model.Company
	Branches []*model.Branch
	Stations []*model.POSStation
	// StationBranchIdx[i] is the index into Branches that Stations[i] belongs to.
	StationBranchIdx []int

	OwnerID   uuid.UUID
	ManagerID uuid.UUID
	CashierID uuid.UUID

	// Sellable holds simple+recipe products orderable at the POS, with a
	// parallel popularity Weight used for order-item selection and
	// procurement sizing.
	Sellable        []*model.Product
	SellableWeights []float64

	// StockTracked holds every product that carries its own stock_movements
	// (simple products, which also appear in Sellable, plus ingredients,
	// which never appear in Sellable).
	StockTracked []*model.Product
	UnitCost     map[uuid.UUID]int64

	// RecipeComponents maps a recipe product ID to its ingredient breakdown.
	RecipeComponents map[uuid.UUID][]model.RecipeComponent

	Discounts []*model.Discount

	StartDate       time.Time
	AvgOrdersPerDay float64
	HourWeights     [24]float64
	BranchWeights   []float64
}

Business holds everything the history generator needs for one seeded company.

func (*Business) TotalDays

func (b *Business) TotalDays(now time.Time) int

TotalDays returns the number of full historical days to simulate: from StartDate through yesterday. Today itself is handled separately by generateTodayHistory, which adds a partial day of activity (through the current hour) while leaving today's session(s) open for live interactive use.

type Config

type Config struct {
	// Seed seeds the deterministic RNG driving every random choice. The same
	// seed always produces the same dataset.
	Seed int64
	// Scale multiplies the average daily order count (and therefore most
	// downstream row counts). 1.0 is the full ~100 orders/day/business
	// dataset described in the design; smaller values are useful for fast
	// local smoke tests.
	Scale float64
}

Config controls the volume and reproducibility of generated data.

type Stats

type Stats struct {
	Companies      int
	Branches       int
	Stations       int
	Users          int
	Products       int
	Discounts      int
	Sessions       int
	Orders         int
	OrderItems     int
	Payments       int
	StockMovements int
	Expenses       int
	JournalEntries int
}

Stats summarizes what Run generated, for the final CLI report.

func Run

func Run(ctx context.Context, database *sql.DB, out io.Writer, cfg Config) (Stats, error)

Run generates the full demo dataset against database, which must already be migrated and empty (checked via a users-table count). It reports progress to out.

func (Stats) String

func (s Stats) String() string

Jump to

Keyboard shortcuts

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