Skip to content

chore: expand gerrit delete activities script#4080

Open
joanagmaia wants to merge 4 commits intomainfrom
chore/expand-gerrit-delete-activities-script
Open

chore: expand gerrit delete activities script#4080
joanagmaia wants to merge 4 commits intomainfrom
chore/expand-gerrit-delete-activities-script

Conversation

@joanagmaia
Copy link
Copy Markdown
Contributor

@joanagmaia joanagmaia commented May 6, 2026

Summary

  • Replaced hardcoded type and date filters with --type and --before-date CLI flags, making the script
    reusable for different cleanup scenarios without code changes.
  • Added a pre-flight count step that queries all three stores (Postgres, Tinybird activities, Tinybird
    activityRelations) in parallel before any deletion, so the operator can see the blast radius upfront.
  • Added an interactive confirmation prompt (skippable with --yes/-y) to prevent accidental mass deletions.
  • Refactored Postgres deletion from a Tinybird-ID-driven batched approach to a direct chunked DELETE ...
    WHERE ... LIMIT 10k loop, removing the dependency on Tinybird to drive the Postgres cleanup.
  • Added input validation for --before-date (YYYY-MM-DD format check) and --type (enum guard against
    VALID_GERRIT_TYPES), with an explicit warning when neither filter is provided (would delete all Gerrit
    activities).

Note

Medium Risk
Moderate risk because it changes a destructive cleanup workflow (Postgres deletes + Tinybird delete jobs) and broadens what can be targeted via CLI filters; safeguards were added but misuse could still cause large deletions.

Overview
Extends the Gerrit activities cleanup tooling by adding a cleanup-gerrit-activities script and making the cleanup script configurable via CLI flags (--type, --before-date, --tb-token, --dry-run, --yes).

The script now does a pre-flight count across PostgreSQL and both Tinybird datasources, prompts for explicit confirmation by default, and switches Postgres cleanup to a direct 10k-chunked DELETE loop (rather than querying IDs from Tinybird) while triggering and optionally waiting for Tinybird delete jobs, persisting job IDs/results to /tmp.

Reviewed by Cursor Bugbot for commit b7386b1. Bugbot is set up for automated code reviews on this repo. Configure here.

joanagmaia added 2 commits May 6, 2026 12:23
…es as filters

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
@joanagmaia joanagmaia requested review from Copilot and mbani01 May 6, 2026 13:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 383dede. Configure here.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 6, 2026 16:23
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants