Add backfill position job by workspace (#5725)
- Removing existing listener that was backfilling created records without position - Switch to a job that backfill all objects within workspace - Adapting `FIND_BY_POSITION` so it can fetch objects without position. Currently we needed to input a number
This commit is contained in:
@ -19,14 +19,14 @@ describe('RecordPositionQueryFactory', () => {
|
||||
it('should return query and params for FIND_BY_POSITION', async () => {
|
||||
const positionValue = 1;
|
||||
const queryType = RecordPositionQueryType.FIND_BY_POSITION;
|
||||
const [query, params] = await factory.create(
|
||||
const [query, params] = factory.create(
|
||||
{ positionValue, recordPositionQueryType: queryType },
|
||||
objectMetadataItem,
|
||||
dataSourceSchema,
|
||||
);
|
||||
|
||||
expect(query).toEqual(
|
||||
`SELECT position FROM ${dataSourceSchema}."${objectMetadataItem.nameSingular}"
|
||||
`SELECT id, position FROM ${dataSourceSchema}."${objectMetadataItem.nameSingular}"
|
||||
WHERE "position" = $1`,
|
||||
);
|
||||
expect(params).toEqual([positionValue]);
|
||||
@ -34,7 +34,7 @@ describe('RecordPositionQueryFactory', () => {
|
||||
|
||||
it('should return query and params for FIND_MIN_POSITION', async () => {
|
||||
const queryType = RecordPositionQueryType.FIND_MIN_POSITION;
|
||||
const [query, params] = await factory.create(
|
||||
const [query, params] = factory.create(
|
||||
{ recordPositionQueryType: queryType },
|
||||
objectMetadataItem,
|
||||
dataSourceSchema,
|
||||
@ -48,7 +48,7 @@ describe('RecordPositionQueryFactory', () => {
|
||||
|
||||
it('should return query and params for FIND_MAX_POSITION', async () => {
|
||||
const queryType = RecordPositionQueryType.FIND_MAX_POSITION;
|
||||
const [query, params] = await factory.create(
|
||||
const [query, params] = factory.create(
|
||||
{ recordPositionQueryType: queryType },
|
||||
objectMetadataItem,
|
||||
dataSourceSchema,
|
||||
@ -64,7 +64,7 @@ describe('RecordPositionQueryFactory', () => {
|
||||
const positionValue = 1;
|
||||
const recordId = '1';
|
||||
const queryType = RecordPositionQueryType.UPDATE_POSITION;
|
||||
const [query, params] = await factory.create(
|
||||
const [query, params] = factory.create(
|
||||
{ positionValue, recordId, recordPositionQueryType: queryType },
|
||||
objectMetadataItem,
|
||||
dataSourceSchema,
|
||||
|
||||
@ -10,7 +10,7 @@ export enum RecordPositionQueryType {
|
||||
}
|
||||
|
||||
type FindByPositionQueryArgs = {
|
||||
positionValue: number;
|
||||
positionValue: number | null;
|
||||
recordPositionQueryType: RecordPositionQueryType.FIND_BY_POSITION;
|
||||
};
|
||||
|
||||
@ -77,10 +77,12 @@ export class RecordPositionQueryFactory {
|
||||
name: string,
|
||||
dataSourceSchema: string,
|
||||
): [RecordPositionQuery, RecordPositionQueryParams] {
|
||||
const positionStringParam = positionValue ? '= $1' : 'IS NULL';
|
||||
|
||||
return [
|
||||
`SELECT position FROM ${dataSourceSchema}."${name}"
|
||||
WHERE "position" = $1`,
|
||||
[positionValue],
|
||||
`SELECT id, position FROM ${dataSourceSchema}."${name}"
|
||||
WHERE "position" ${positionStringParam}`,
|
||||
positionValue ? [positionValue] : [],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user