Skip to content

Commit

Permalink
Add extra filter by scope for optimize performance for get relations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-weber authored Nov 29, 2024
1 parent 030b6aa commit 084fcc6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/services/entry/actions/get-related-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ export async function getRelatedEntries(
endToStart ? 'l.fromId' : 'l.toId',
)
.join('entries', 'entries.entryId', endToStart ? 'l.toId' : 'l.fromId')
.where('isDeleted', false)
.where('depth', '<', 5);
.where((builder) => {
builder.where({isDeleted: false});

builder.andWhere('depth', '<', 5);

if (scope) {
builder.andWhere('entries.scope', scope);
}
});
});
})
.select()
Expand Down

0 comments on commit 084fcc6

Please sign in to comment.