fix: avoid no-op Google Sheets backfill rewrites#8864
fix: avoid no-op Google Sheets backfill rewrites#8864
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughRefactors the Google Sheets backfill to read existing sheet values and only clear/write when content differs; adds robust read-failure fallback and warning logs. Adds a comprehensive test suite covering unchanged content, differing content, empty sheets, read failures, and missing records. Changes
Sequence DiagramsequenceDiagram
participant Backfill as Backfill Service
participant Prisma as Prisma Database
participant Sheets as Google Sheets API
Backfill->>Prisma: fetch googleSheetsSync config
alt sync not found
Backfill->>Backfill: log warning, skip
else sync found
Backfill->>Prisma: fetch journey & events
alt journey not found
Backfill->>Backfill: log warning, skip
else journey found
Backfill->>Sheets: read existing sheet values (readValues)
alt read fails
Backfill->>Sheets: write all values (writeValues)
Backfill->>Backfill: log warning about read failure
else read succeeds
Backfill->>Backfill: compare existing vs new (isSheetContentUnchanged)
alt content unchanged
Backfill->>Backfill: skip clear/write
else content changed
Backfill->>Sheets: clear sheet (clearSheet)
Backfill->>Sheets: write new values (writeValues)
end
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
|
View your CI Pipeline Execution ↗ for commit e7d793d
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.ts`:
- Around line 330-331: fullRange is built using a raw sheetName which breaks A1
parsing for titles with spaces/apostrophes; escape the sheet name before
concatenating by replacing each single quote with two single quotes and wrapping
the name in single quotes (per Google Sheets A1 syntax) so use an escaped
variant instead of sheetName when building fullRange (refer to columnIndexToA1,
lastColumnA1, and fullRange); update the code that calls readValues() to use the
escaped sheet name, or add a small helper like escapeSheetName(sheetName) that
performs the replace and quoting and use that in place of sheetName, ensuring
readFailed/contentUnchanged behavior no longer triggers for valid sheet titles.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e0fd3d9f-af76-4ecb-bf2f-9cfb4d304ba6
📒 Files selected for processing (2)
apis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.spec.tsapis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.ts
apis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.ts
Outdated
Show resolved
Hide resolved
|
I see you added the "on stage" label, I'll get this merged to the stage branch! |
Summary
A1to computed last row/column)Why
Button-click-only activity can trigger backfill jobs even when there are no exportable submission events. Previously this still cleared/re-wrote the sheet, causing Google Drive to show a file edit with no meaningful data change.
Testing
pnpm nx test api-journeys-modern --runInBand --testPathPattern=backfill.spec.ts(fails in current branch due existing unrelated TS error:apis/api-journeys-modern/test/prismaMock.tsimporting non-exportedPrismaClient)pnpm exec eslint apis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.ts apis/api-journeys-modern/src/workers/googleSheetsSync/service/backfill.spec.ts(repo currently uses Nx lint config; standalone ESLint v9 flat-config entrypoint not present)Slack Thread
Summary by CodeRabbit
Tests
Bug Fixes
Refactor