fix: bug where importDataRecords would overwrite columnDefs#330
fix: bug where importDataRecords would overwrite columnDefs#330
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the importDataRecords job where column definitions were being overwritten on each batch instead of being accumulated across all batches.
Changes:
- Fixed columnDefs accumulator initialization to start with existing columns and persist outside the batch loop
- Improved Google Sheets row counting accuracy by expanding the column range from A:A to A:Z
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/server/jobs/importDataRecords.ts | Moved columnDefsAccumulator initialization outside the loop and updateDataSource call after all batches complete, fixing the overwrite bug |
| src/server/adaptors/googlesheets.ts | Changed getRecordCount range from A:A to A:Z to count rows with data in any of the first 26 columns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async getRecordCount(): Promise<number | null> { | ||
| try { | ||
| const url = `https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${encodeURIComponent(this.sheetName)}!A:A`; | ||
| const url = `https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${encodeURIComponent(this.sheetName)}!A:Z`; |
There was a problem hiding this comment.
Changing from A:A to A:Z improves accuracy by counting rows with data in any of the first 26 columns, rather than only rows with data in column A. However, this still won't count rows that only have data beyond column Z. For better consistency with fetchAll() (which fetches all columns), consider using a larger range like A:ZZ or document this 26-column limitation.
| const url = `https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${encodeURIComponent(this.sheetName)}!A:Z`; | |
| const url = `https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${encodeURIComponent(this.sheetName)}!A:ZZ`; |
d8be06a to
fee3d55
Compare
No description provided.