mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-24 06:48:42 +03:00
Fix limit pagination (#2692)
* Fix limit parameter * Increaze max_row for each workspaces
This commit is contained in:
parent
d3615ba0d3
commit
cefac8435b
@ -25,6 +25,7 @@ import { ViewType } from '@/views/types/ViewType';
|
||||
import { mapViewFieldsToBoardFieldDefinitions } from '@/views/utils/mapViewFieldsToBoardFieldDefinitions';
|
||||
import { mapViewFiltersToFilters } from '@/views/utils/mapViewFiltersToFilters';
|
||||
import { mapViewSortsToSorts } from '@/views/utils/mapViewSortsToSorts';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { useUpdateCompanyBoardCardIds } from '../hooks/useUpdateBoardCardIds';
|
||||
import { useUpdateCompanyBoard } from '../hooks/useUpdateCompanyBoardColumns';
|
||||
@ -98,27 +99,34 @@ export const HooksCompanyBoardEffect = () => {
|
||||
objectMetadataItem?.fields ?? [],
|
||||
);
|
||||
|
||||
useFindManyObjectRecords({
|
||||
skip: !pipelineSteps.length,
|
||||
objectNamePlural: 'opportunities',
|
||||
filter: filter,
|
||||
orderBy: orderBy,
|
||||
onCompleted: useCallback(
|
||||
(data: PaginatedObjectTypeResults<Opportunity>) => {
|
||||
const pipelineProgresses: Array<Opportunity> = data.edges.map(
|
||||
(edge) => edge.node,
|
||||
);
|
||||
const { fetchMoreObjects: fetchMoreOpportunities } = useFindManyObjectRecords(
|
||||
{
|
||||
skip: !pipelineSteps.length,
|
||||
objectNamePlural: 'opportunities',
|
||||
filter: filter,
|
||||
orderBy: orderBy,
|
||||
onCompleted: useCallback(
|
||||
(data: PaginatedObjectTypeResults<Opportunity>) => {
|
||||
const pipelineProgresses: Array<Opportunity> = data.edges.map(
|
||||
(edge) => edge.node,
|
||||
);
|
||||
|
||||
updateCompanyBoardCardIds(pipelineProgresses);
|
||||
updateCompanyBoardCardIds(pipelineProgresses);
|
||||
|
||||
setOpportunities(pipelineProgresses);
|
||||
setIsBoardLoaded(true);
|
||||
},
|
||||
[setIsBoardLoaded, updateCompanyBoardCardIds],
|
||||
),
|
||||
});
|
||||
setOpportunities(pipelineProgresses);
|
||||
setIsBoardLoaded(true);
|
||||
},
|
||||
[setIsBoardLoaded, updateCompanyBoardCardIds],
|
||||
),
|
||||
},
|
||||
);
|
||||
useEffect(() => {
|
||||
if (isDefined(fetchMoreOpportunities)) {
|
||||
fetchMoreOpportunities();
|
||||
}
|
||||
}, [fetchMoreOpportunities]);
|
||||
|
||||
useFindManyObjectRecords({
|
||||
const { fetchMoreObjects: fetchMoreCompanies } = useFindManyObjectRecords({
|
||||
skip: !opportunities.length,
|
||||
objectNamePlural: 'companies',
|
||||
filter: {
|
||||
@ -131,6 +139,12 @@ export const HooksCompanyBoardEffect = () => {
|
||||
}, []),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isDefined(fetchMoreCompanies)) {
|
||||
fetchMoreCompanies();
|
||||
}
|
||||
}, [fetchMoreCompanies]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!objectMetadataItem) {
|
||||
return;
|
||||
|
@ -8,6 +8,7 @@ import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimis
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { getRecordOptimisticEffectDefinition } from '@/object-record/graphql/optimistic-effect-definition/getRecordOptimisticEffectDefinition';
|
||||
import { DEFAULT_SEARCH_REQUEST_LIMIT } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { logError } from '~/utils/logError';
|
||||
import { capitalize } from '~/utils/string/capitalize';
|
||||
@ -30,7 +31,7 @@ export const useFindManyObjectRecords = <
|
||||
objectNamePlural,
|
||||
filter,
|
||||
orderBy,
|
||||
limit,
|
||||
limit = DEFAULT_SEARCH_REQUEST_LIMIT,
|
||||
onCompleted,
|
||||
skip,
|
||||
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'> & {
|
||||
@ -72,8 +73,8 @@ export const useFindManyObjectRecords = <
|
||||
skip: skip || !objectMetadataItem || !objectNamePlural,
|
||||
variables: {
|
||||
filter: filter ?? {},
|
||||
limit: limit,
|
||||
orderBy: orderBy ?? {},
|
||||
limit: limit ?? 30,
|
||||
},
|
||||
onCompleted: (data) => {
|
||||
if (objectMetadataItem) {
|
||||
|
@ -15,7 +15,7 @@ export type OrderBy =
|
||||
| 'AscNullsFirst'
|
||||
| 'DescNullsFirst';
|
||||
|
||||
const DEFAULT_SEARCH_REQUEST_LIMIT = 30;
|
||||
export const DEFAULT_SEARCH_REQUEST_LIMIT = 60;
|
||||
|
||||
// TODO: use this for all search queries, because we need selectedEntities and entitiesToSelect each time we want to search
|
||||
// Filtered entities to select are
|
||||
|
@ -50,6 +50,8 @@ export class WorkspaceManagerService {
|
||||
schemaName,
|
||||
);
|
||||
|
||||
await this.setWorkspaceMaxRow(workspaceId, schemaName);
|
||||
|
||||
await this.workspaceMigrationService.insertStandardMigrations(workspaceId);
|
||||
|
||||
await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
|
||||
@ -217,6 +219,23 @@ export class WorkspaceManagerService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* We are updating the pg_graphql max_rows from 30 (default value) to 60
|
||||
*
|
||||
* @params workspaceId, schemaName
|
||||
* @param workspaceId
|
||||
*/
|
||||
private async setWorkspaceMaxRow(workspaceId, schemaName) {
|
||||
const workspaceDataSource =
|
||||
await this.workspaceDataSourceService.connectToWorkspaceDataSource(
|
||||
workspaceId,
|
||||
);
|
||||
await workspaceDataSource.query(
|
||||
`comment on schema ${schemaName} is e'@graphql({"max_rows": 60})'`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* We are prefilling a few standard objects with data to make it easier for the user to get started.
|
||||
|
Loading…
Reference in New Issue
Block a user