Skip to content

Commit

Permalink
Fix nested sorting issue for 'planVersion'
Browse files Browse the repository at this point in the history
  • Loading branch information
manelcecs committed Apr 23, 2024
1 parent 44e15c2 commit 07a6616
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/domain-services/flows/flow-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,25 @@ export class FlowService {
let joinQuery = dbConnection
.queryBuilder()
.distinct('flowObject.flowID', 'flowObject.versionID')
.from('flowObject')
.where('objectType', entityCondKeyFlowObjectType);
.from('flowObject');

if (result._tag === 'Right') {
joinQuery = joinQuery
.join(entity, 'flowObject.objectID', `${entity}.id`)
.select(mappedOrderBy.column)
.select(`${entity}.${mappedOrderBy.column}`) // This is needed since we must select the column to order by
.where('objectType', entityCondKeyFlowObjectType)
.orderBy(mappedOrderBy.column, mappedOrderBy.order);
} else {
// Collect fisrt part of the entity key by the fisrt Case letter
const entityKey = entity.slice(0, entity.search(/[A-Z]/));

joinQuery = joinQuery
.join(orderBy.entity, 'flowObject.objectID', `${entityKey}Id`)
.select(mappedOrderBy.column)
.join(
orderBy.entity,
'flowObject.objectID',
`${orderBy.entity}.${entityKey}Id`
)
.select(`${orderBy.entity}.${mappedOrderBy.column}`) // This is needed since we must select the column to order by
.where('objectType', entityKey)
.orderBy(mappedOrderBy.column, mappedOrderBy.order);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class SearchFlowByFiltersStrategy implements FlowSearchStrategy {

const sortByFlowIDs: UniqueFlowEntity[] = [];
if (isSortByEntity) {
console.log('HERE');
// Get the flowIDs using the orderBy entity
const flowIDsFromSortingEntity: UniqueFlowEntity[] =
await this.flowService.getFlowIDsFromEntity(
Expand Down

0 comments on commit 07a6616

Please sign in to comment.