Skip to content

fix/seed-company-settings-pagination-batch-dry-run [ GSSOC ]#827

Open
rudra3007-pro wants to merge 1 commit into
ritesh-1918:gssocfrom
rudra3007-pro:fix/seed-company-settings-pagination-batch-dry-run
Open

fix/seed-company-settings-pagination-batch-dry-run [ GSSOC ]#827
rudra3007-pro wants to merge 1 commit into
ritesh-1918:gssocfrom
rudra3007-pro:fix/seed-company-settings-pagination-batch-dry-run

Conversation

@rudra3007-pro
Copy link
Copy Markdown

Closes #826

────────────────────────────────────────────────────────────

Summary

Fixes silent data truncation (> 1 000 rows), reduces N insert round-trips to 1,
eliminates the duplicate Supabase client, and adds a --dry-run flag for safe
production previews. All changes are backward-compatible; default behaviour
is identical for installations under 1 000 tickets.

────────────────────────────────────────────────────────────

What Changed

New helpers

  • _build_client() — constructs the Supabase client from env vars with a clear
    EnvironmentError if either variable is missing; called once in main and
    passed down.
  • _fetch_all_pages(client, table, select) — range-based paginator that loops
    until a page smaller than _SUPABASE_PAGE_SIZE (1 000) is returned. Used by
    both _get_unique_company_ids and _get_existing_company_ids.
  • _build_records(company_ids) — builds the list of dicts for batch insert,
    including an explicit created_at timestamp.
  • _parse_args() — argparse-based CLI with --dry-run flag.

seed_company_settings()

  • Now accepts client: Client and dry_run: bool instead of creating its own
    client.
  • Replaced per-company insert loop with a single insert(records).execute().
  • Dry-run path logs intended records and returns without writing.

verify_seed()

  • Now accepts client: Client — no second create_client() call.
  • Uses shared _get_unique_company_ids / _get_existing_company_ids helpers.

Removed

  • count="exact" from all .select() calls (result was never read).
  • Direct create_client() calls inside both functions.
  • Per-row insert loop.

────────────────────────────────────────────────────────────

Risk & Compatibility

  • No schema changes — insert payload shape is identical plus created_at.
  • Pagination is transparent; results are the same as before for < 1 000 rows.
  • --dry-run exits 0 always; existing CI invocations without the flag are
    unaffected.

────────────────────────────────────────────────────────────

Testing Done

  • Runs successfully on empty database (no_tickets path)
  • Runs successfully when all companies already have settings (complete path)
  • Creates correct records for new companies (success path)
  • Paginator fetches all rows when tickets > 1 000 (manual test or mock)
  • --dry-run logs records and exits 0 without writing
  • Missing SUPABASE_URL prints clear error and exits 1
  • Batch insert payload contains created_at field
  • verify_seed returns True after successful seed
  • verify_seed returns False when a company is missing settings

@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@rudra3007-pro is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac862b1c-2bf7-4fd4-bdfd-76c0416bea63

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@rudra3007-pro rudra3007-pro changed the title fix/seed-company-settings-pagination-batch-dry-run fix/seed-company-settings-pagination-batch-dry-run [ GSSOC ] May 31, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @rudra3007-pro! 🙌

Thank you so much for your excellent contribution: "fix/seed-company-settings-pagination-batch-dry-run [ GSSOC ]"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR quality:exceptional Exceptional code quality level:intermediate Intermediate level difficulty type:bug Bug fix labels May 31, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @rudra3007-pro! 🙌

Thank you so much for your excellent contribution: "fix/seed-company-settings-pagination-batch-dry-run [ GSSOC ]"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants