feat: find duplicate objects init (#4038)

* feat: find duplicate objects backend init

* refactor: move duplicate criteria to constants

* fix: correct constant usage after type change

* feat: skip query generation in case its not necessary

* feat: filter out existing duplicate

* feat: FE queries and hooks

* feat: show duplicates on FE

* refactor: should-skip-query moved to workspace utils

* refactor: naming improvements

* refactor: current record typings/parsing improvements

* refactor: throw error if existing record not found

* fix: domain -> domainName duplicate criteria

* refactor: fieldNames -> columnNames

* docs: add explanation to duplicate criteria collection

* feat: add person linkedinLinkUrl as duplicate criteria

* feat: throw early when bot id and data are empty

* refactor: trying to improve readability of filter criteria query

* refactor: naming improvements

* refactor: remove shouldSkipQuery

* feat: resolve empty array in case of empty filter

* feat: hide whole section in case of no duplicates

* feat: FE display list the same way as relations

* test: basic unit test coverage

* Refactor Record detail section front

* Use Create as input argument of findDuplicates

* Improve coverage

* Fix

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
rostaklein
2024-02-24 19:12:21 +01:00
committed by GitHub
parent 05c206073d
commit 1b04dfe3c6
30 changed files with 875 additions and 100 deletions

View File

@ -1,4 +1,4 @@
import { arrayToChunks } from '~/utils/array/array-to-chunks';
import { arrayToChunks } from '~/utils/array/arrayToChunks';
describe('arrayToChunks', () => {
it('should split an array into subarrays of a given size', () => {

View File

@ -0,0 +1,33 @@
import { moveArrayItem } from '~/utils/array/moveArrayItem';
describe('moveArrayItem', () => {
it('should return an empty array if provided with empty array', () => {
expect(moveArrayItem([], { fromIndex: 0, toIndex: 0 })).toEqual([]);
});
it('should return the same array if fromIndex is larger than array.length', () => {
expect(moveArrayItem([1, 2], { fromIndex: 3, toIndex: 0 })).toEqual([1, 2]);
});
it('should return the same array if toIndex is larger than array.length', () => {
expect(moveArrayItem([1, 2], { fromIndex: 0, toIndex: 3 })).toEqual([1, 2]);
});
it('should return the same array if fromIndex is smaller than 0', () => {
expect(moveArrayItem([1, 2], { fromIndex: -1, toIndex: 0 })).toEqual([
1, 2,
]);
});
it('should return the same array if toIndex is smaller than 0', () => {
expect(moveArrayItem([1, 2], { fromIndex: 1, toIndex: -1 })).toEqual([
1, 2,
]);
});
it('should move array items based on fromIndex and toIndex', () => {
expect(moveArrayItem([1, 2, 3], { fromIndex: 0, toIndex: 1 })).toEqual([
2, 1, 3,
]);
});
});