Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,29 @@ Apply database migrations:
pnpm --filter @statify/db prisma:migrate:dev
```

Seed a small demo dataset (catalog, accounts, and listening history) so the
app has data on first run:

```bash
pnpm --filter @statify/db db:seed
```

Run the frontend and backend:

```bash
pnpm dev
```

Then sign in with a seeded account to see populated analytics:

| Field | Value |
| -------- | -------------------- |
| Email | `alex@statify.local` |
| Password | `statify123` |

All five seeded accounts (`admin`, `alex`, `jordan`, `sam`, `riley`) share the
same password and have listening history.

Default local URLs:

| Service | URL |
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/seed/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const DEFAULT_SEED_COUNTS: SeedCounts = {
albums: 200,
tracks: 600,
playlists: 60,
historyUsers: 3,
historyPerUser: { min: 60, max: 110 },
historyUsers: 5,
historyPerUser: { min: 90, max: 160 },
historyDays: 21,
};

Expand Down
4 changes: 3 additions & 1 deletion packages/db/src/seed/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export async function runSeed(
});
const userIdByEmail = new Map(users.map((u) => [u.email, u.id]));

const corpus = generateCorpus(counts);
// Anchor seeded play timestamps to the run date so time-windowed analytics
// (e.g. Trending: last 7 days vs the prior 7) have data on the current date.
const corpus = generateCorpus(counts, new Date());

const artistIds = await insertArtists(prisma, corpus.artists);
logger.info(`Inserted ${corpus.artists.length} artists`);
Expand Down
10 changes: 8 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ pnpm install
pnpm --filter @statify/db run prisma:generate
pnpm --filter @statify/db run prisma:migrate:deploy

# Seed a small demo dataset so the app has data on first run.
# Set SKIP_SEED=1 to skip this (e.g. for a production bootstrap).
if [[ "${SKIP_SEED:-0}" != "1" ]]; then
pnpm --filter @statify/db run db:seed
fi

# Build steps decide NODE_ENV themselves; don't leak a dev value from .env.
unset NODE_ENV
pnpm build

echo
echo "setup complete."
echo " next: pnpm dev # start api on :4000 and web on :3000"
echo " seed: pnpm --filter @statify/db run db:seed"
echo " next: pnpm dev # start api on :4000 and web on :3000"
echo " login: alex@statify.local / statify123 (a seeded account with data)"
Loading