Skip to content

feat: make seed-performance-testing script configurable from CLI#29557

Open
SinghaAnirban005 wants to merge 2 commits into
calcom:mainfrom
SinghaAnirban005:feat/cli
Open

feat: make seed-performance-testing script configurable from CLI#29557
SinghaAnirban005 wants to merge 2 commits into
calcom:mainfrom
SinghaAnirban005:feat/cli

Conversation

@SinghaAnirban005

Copy link
Copy Markdown
Contributor

What does this PR do?

Resolves the TODO: Make it more structured and configurable from CLI in seed-performance-testing.ts.

Video Demo (if applicable):

Screencast.from.2026-04-26.19-30-14.webm

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Note for reviewers: The steps below require a locally reachable Postgres instance. The project's docker-compose.yml runs the database inside Docker , to connect from the host you will need to temporarily expose port 5432. This is a local only change and is not part of this PR.

In your local docker-compose.yml, add the following under the database service, run docker compose up -d database, then follow the steps below. Remove the port mapping when done.

database:
  ports:
    - "5432:5432"
  1. In .env
   DATABASE_URL=postgresql://unicorn_user:magical_password@localhost:5432/calendso
   DATABASE_DIRECT_URL=postgresql://unicorn_user:magical_password@localhost:5432/calendso
  1. Run docker-compose up -d database

  2. cd into /scripts

  3. Three modes are available

  • --bookings <n> — number of bookings per event type (default: 100)
  • --start-from <n> — start user index for many-users mode (default: 0), enables resuming an interrupted run
  • --till-user <n> — end user index for many-users mode (default: 20)
  • --mode many-bookings | many-users — replaces the previously commented-out createManyDifferentUsers call

Examples

  • npx ts-node --transpile-only ./scripts/seed-performance-testing.ts
  • npx ts-node --transpile-only ./scripts/seed-performance-testing.ts --bookings 50
  • npx ts-node --transpile-only ./scripts/seed-performance-testing.ts --mode many-users --till-user 100
  • npx ts-node --transpile-only ./scripts/seed-performance-testing.ts --mode many-users --start-from 500 --till-user 1000

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @SinghaAnirban005! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49720bdc-bbb5-4700-98d6-b9313caee8d9

📥 Commits

Reviewing files that changed from the base of the PR and between bbce0fc and 18a147d.

📒 Files selected for processing (1)
  • scripts/seed-performance-testing.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/seed-performance-testing.ts

📝 Walkthrough

Walkthrough

This pull request refactors the performance testing seed script to support CLI-driven configuration and programmatic test data generation. It adds dotenv integration and a parseArgs() function that validates the --mode flag (many-bookings or many-users), parses numeric parameters (--bookings, --start-from, --till-user), and enforces constraint validation. The script's booking data generation is refactored from hardcoded object arrays to map()-generated arrays for yoga and tennis classes. The execution flow is reorganized with a new main() dispatcher function that routes to the appropriate seeding routine based on parsed arguments and returns proper exit codes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding CLI configurability to the seed-performance-testing script, which resolves the TODO mentioned in the PR description.
Description check ✅ Passed The description is clearly related to the changeset, explaining what the PR does, providing testing instructions, and documenting available CLI options with examples.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/seed-performance-testing.ts`:
- Around line 34-40: parseNonNegativeInt currently uses parseInt which accepts
truncated/ambiguous inputs (e.g. "10abc", "3.5"); change it to strictly validate
the raw string before conversion: require raw (or fallback string) to match the
integer-regex /^[0-9]+$/ (reject empty/negative/decimal/trailing chars), then
parse with Number or parseInt and ensure Number.isFinite and >= 0. Update
parseNonNegativeInt to accept the flag name (already present) and produce the
same exit/error behavior for invalid inputs; this will harden CLI flags like
--bookings, --start-from, and --till-user against malformed values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a462535c-ae7d-4c3e-8c3d-ae4d5644bdcd

📥 Commits

Reviewing files that changed from the base of the PR and between 9104545 and bbce0fc.

📒 Files selected for processing (1)
  • scripts/seed-performance-testing.ts

Comment thread scripts/seed-performance-testing.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant