# Data generator Fills a MongoDB database with analytics data that follows the data model contract of `@openvidu-dashboard/typings`: a deterministic scenario S, M or L over a number of days ending now. The backend integration tests use it for their query plan and latency checks, and `./dashboard.sh demo` uses it for the local demo database. Before inserting, `src/schema.ts` creates every collection, index and TTL of the contract and gives the plain collections the contract validator with `validationAction: error`, so a document that drifts from the contract fails the run (`track_stats` takes no validator as a time-series collection). `src/contract.ts` turns each model document into its stored shape: the model's bookkeeping removed, absent fields omitted and every number in the BSON type its schema declares. The package is also a library for the backend integration tests (`dashboard-ce/backend/test/`): `./generator` (`generate(db, options)`), `./context` (`queryContext(db)`: the data range and sample identifiers), `./plan` (explain summaries used by the `expectIndexBacked` harness) and `./schema` (`createCollections()`). Requirements: the workspace installed (`./dashboard.sh install`), a reachable MongoDB (8.x; time-series collections are used when the server accepts them) and a user allowed to create and drop the target database. Run the commands from this directory. ## Usage ```sh pnpm generate --uri "$MONGO_URI" --db ov_data_s --scenario S --days 30 --drop pnpm generate --uri "$MONGO_URI" --db ov_data_m --scenario M --days 7 --drop pnpm generate --uri "$MONGO_URI" --db ov_data_l --scenario L --days 1 --drop --stats-mode track ``` | Option | Default | Meaning | | ----------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- | | `--uri`, `--db` | required | Connection string and target database | | `--scenario S\|M\|L` | required | Rooms per day, sessions per day and average room size (table below) | | `--days ` | required | Days of history ending now | | `--stats-mode participant\|track` | `participant` | One `track_stats` document per participant and direction, or per track | | `--seed ` | `1` | Seed of the pseudo-random generator (mulberry32); same seed, same data | | `--retention-events-days ` | `7` | Only raw events inside this window are written (TTL index on `ts`) | | `--retention-stats-days ` | `7` | Only stats inside this window are written (`expireAfterSeconds`) | | `--retention-tracks-days ` | `7` | `expiresAt` of tracks and subscriptions; expired ones are not written | | `--retention-entities-days ` | `90` | `expiresAt = closedAt + retention` on closed entities | | `--retention-rollups-5min-days ` | `7` | Only 5-minute rollups inside this window are written (TTL index on `bucket`) | | `--drop` | off | Drop the database first | | `--plain-stats` | off | Force the plain-collection fallback for `track_stats` | | `--five-minute-rollups` | off | Write `analytics_5min` inside the 5-minute rollup window | | `--node-rollups` | off | With `--media-nodes`: write the `node: