-
Notifications
You must be signed in to change notification settings - Fork 4.5k
FIX: export view not exporting all records #15509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: export view not exporting all records #15509
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR fixes a critical pagination bug in the export functionality where only a subset of records were being exported (560 out of 1200 in the reported case).
Root Cause:
The useLazyFetchAllRecords hook was calling fetchMoreRecordsLazy() without passing the limit parameter. This caused the function to fall back to its default parameter value of DEFAULT_SEARCH_REQUEST_LIMIT (60 records) instead of using the configured pageSize (200 records for exports).
The Fix:
Changed line 90 in useLazyFetchAllRecords.ts from:
const rawResult = await fetchMoreRecordsLazy();to:
const rawResult = await fetchMoreRecordsLazy(limit);This ensures that subsequent pagination requests during export use the same page size as the initial request, allowing all records to be fetched correctly.
Impact:
- Exports now correctly retrieve all records from views
- The fix is minimal and surgical, changing only the problematic function call
- No changes to API contracts or function signatures
- Existing tests should continue to pass as the function signature already supported the optional
limitparameter
Confidence Score: 5/5
- This PR is safe to merge with minimal risk - it's a one-line fix that correctly addresses a clear pagination bug
- The fix is straightforward and correct: it passes the
limitparameter that was already available in scope to a function that was designed to accept it. The function signature inuseLazyFetchMoreRecordsWithPagination.tsline 92 showsasync (limit = DEFAULT_SEARCH_REQUEST_LIMIT), confirming this parameter was always intended to be passed. The change eliminates a mismatch between the page size calculation and actual fetching behavior, resolving the incomplete export issue without introducing new logic or side effects - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/twenty-front/src/modules/object-record/hooks/useLazyFetchAllRecords.ts | 5/5 | Fixed pagination bug by passing limit parameter to fetchMoreRecordsLazy, preventing premature termination of exports |
Sequence Diagram
sequenceDiagram
participant User
participant ExportFlow as Export Flow
participant Hook as useLazyFetchAllRecords
participant LazyFetch as fetchMoreRecordsLazy
participant API as GraphQL API
User->>ExportFlow: Click "Export View"
ExportFlow->>Hook: Call fetchAllRecords()<br/>(limit=200)
Hook->>API: Initial query (limit=200)
API-->>Hook: Returns 200 records + hasNextPage=true
alt Before Fix
Hook->>LazyFetch: fetchMoreRecordsLazy()<br/>(no limit param)
Note over LazyFetch: Uses DEFAULT_SEARCH_REQUEST_LIMIT=60
LazyFetch->>API: Fetch with limit=60
API-->>LazyFetch: Returns 60 records
Note over Hook: Calculates remaining pages<br/>using limit=200, but fetches<br/>only 60 per page
Note over Hook: Stops prematurely<br/>(560 out of 1200 records)
end
alt After Fix
Hook->>LazyFetch: fetchMoreRecordsLazy(200)<br/>(passes limit param)
Note over LazyFetch: Uses provided limit=200
LazyFetch->>API: Fetch with limit=200
API-->>LazyFetch: Returns 200 records
Note over Hook: Continues until all pages fetched
Hook-->>ExportFlow: All 1200 records
end
ExportFlow-->>User: Complete export with all records
1 file reviewed, no comments
charlesBochet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @shantanugupta2004 :)
|
Thanks @shantanugupta2004 for your contribution! |
Fixes twentyhq#15508 Addresses the issue where the "Export View" functionality was not exporting all records from a view. Users reported that only a subset of records were exported, even when the view contained more. This led to incomplete data exports. The core of the problem was found within the `useLazyFetchAllRecords` hook. The `fetchMoreRecordsLazy` function, which is responsible for fetching subsequent pages of data during the export process, was inadvertently using a default page limit (`DEFAULT_SEARCH_REQUEST_LIMIT` of 60 records) instead of the intended `pageSize` (200 records). This discrepancy caused the export process to prematurely stop fetching records. The PR modifies `packages/twenty-front/src/modules/object-record/hooks/useLazyFetchAllRecords.ts` to explicitly pass the `limit` parameter (which correctly reflects the `pageSize`) to the `fetchMoreRecordsLazy` function. This ensures that all subsequent data fetches during an export operation adhere to the configured page size, allowing for the complete retrieval of all records.

Fixes #15508
Addresses the issue where the "Export View" functionality was not exporting all records from a view. Users reported that only a subset of records were exported, even when the view contained more. This led to incomplete data exports.
The core of the problem was found within the
useLazyFetchAllRecordshook. ThefetchMoreRecordsLazyfunction, which is responsible for fetching subsequent pages of data during the export process, was inadvertently using a default page limit (DEFAULT_SEARCH_REQUEST_LIMITof 60 records) instead of the intendedpageSize(200 records). This discrepancy caused the export process to prematurely stop fetching records.The PR modifies
packages/twenty-front/src/modules/object-record/hooks/useLazyFetchAllRecords.tsto explicitly pass thelimitparameter (which correctly reflects thepageSize) to thefetchMoreRecordsLazyfunction. This ensures that all subsequent data fetches during an export operation adhere to the configured page size, allowing for the complete retrieval of all records.