Skip to content

⚡ Optimize SEO canonical audit with batch updates#69

Open
Snider wants to merge 4 commits intodevfrom
perf/seo-audit-batch-update-14844739723748388262
Open

⚡ Optimize SEO canonical audit with batch updates#69
Snider wants to merge 4 commits intodevfrom
perf/seo-audit-batch-update-14844739723748388262

Conversation

@Snider
Copy link
Contributor

@Snider Snider commented Feb 2, 2026

💡 What: Optimized AuditCanonicalUrls command to perform a batch update for protocol fixes instead of iterating and saving each record individually.
🎯 Why: Solves the N+1 update performance issue where fixing many records would result in many database queries.
📊 Measured Improvement: Replaced N update queries with 1 update query. Verified with a new regression test src/Core/Tests/Feature/SeoAuditCanonicalTest.php which passes.


PR created automatically by Jules for task 14844739723748388262 started by @Snider

Summary by CodeRabbit

  • Chores

    • Improved CI/CD pipeline: Enhanced error handling in GitHub Actions workflows with additional SARIF sanitization for code analysis tools.
    • Optimized SEO audit command to use batch updates for canonical URL protocol fixes, improving performance.
  • Tests

    • Added comprehensive feature tests for SEO canonical URL auditing functionality.

Replaces N+1 update loop with a single batch update query in `AuditCanonicalUrls` command.
Adds a reproduction feature test `SeoAuditCanonicalTest`.
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

QA Pipeline Results

Check Status Details
Tests 207 tests, 410 assertions
PHPStan 0 errors
Psalm 1 issues
Code Style 0 files need formatting
Security 0 vulnerabilities
Artifacts
  • test-results.xml - JUnit test results
  • phpstan.json - PHPStan analysis
  • psalm.json / psalm.sarif - Psalm analysis
  • pint.json - Code style report
  • audit.json - Security audit

Generated by core php qa pipeline

- Remove stderr redirection (`2>&1`) from Psalm, PHPStan, Pint, and Composer Audit commands to prevent progress output from corrupting JSON/SARIF files.
- Upgrade `github/codeql-action/upload-sarif` to `v4` to address deprecation warning and invalid SARIF handling.
Adds a post-processing step in the QA pipeline to sanitize `psalm.sarif` by ensuring all location coordinates (startLine, startColumn, etc.) are at least 1, as required by the SARIF schema. This resolves the `upload-sarif` action failure.
Uses `jq`'s `walk` function to recursively sanitize all `physicalLocation` objects in the SARIF file, ensuring startLine/startColumn/etc are always at least 1. This fixes validation errors from the `upload-sarif` action.
@Snider Snider marked this pull request as ready for review February 5, 2026 03:24
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

GitHub Actions workflow updated with improved error handling and SARIF sanitization for Psalm. Console command refactored to use batch database updates instead of per-record persistence. Comprehensive feature test added for canonical URL auditing functionality.

Changes

Cohort / File(s) Summary
Workflow Configuration
.github/workflows/qa.yml
Removed stderr redirection from phpstan, psalm, pint, and audit commands; added SARIF sanitization step for Psalm to clamp line/column values to minimum of 1; updated upload-sarif action to v4.
Command Refactoring
src/Core/Seo/Console/Commands/AuditCanonicalUrls.php
Optimized protocol fix logic by replacing per-record updates with a single batch whereIn()->update() call; added import statements for SeoMetadata and DB.
Feature Test
src/Core/Tests/Feature/SeoAuditCanonicalTest.php
New test file validating the seo:audit-canonical command with --fix flag; includes TestSeoable model, test setup with in-memory tables, and assertions for protocol issue fixes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 With batches swift and SARIF clean,
The audit command works serene,
No stderr noise shall cloud the way,
Just pristine updates, bright as day!
Tests confirmed with protocol care,
Our URLs now beyond compare! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '⚡ Optimize SEO canonical audit with batch updates' clearly and specifically describes the main change: replacing per-record updates with a single batch update in the SEO audit command.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/seo-audit-batch-update-14844739723748388262

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

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.

1 participant