perf: Add teamId to search query to help with query planning
This commit is contained in:
@@ -477,26 +477,18 @@ class Document extends ParanoidModel {
|
|||||||
resultsQuery,
|
resultsQuery,
|
||||||
countQuery,
|
countQuery,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Final query to get associated document data
|
// Final query to get associated document data
|
||||||
const documents = await this.findAll({
|
const documents = await this.findAll({
|
||||||
where: {
|
where: {
|
||||||
id: map(results, "id"),
|
id: map(results, "id"),
|
||||||
|
teamId: team.id,
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Collection,
|
model: Collection,
|
||||||
as: "collection",
|
as: "collection",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
model: User,
|
|
||||||
as: "createdBy",
|
|
||||||
paranoid: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: User,
|
|
||||||
as: "updatedBy",
|
|
||||||
paranoid: false,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -620,9 +612,11 @@ class Document extends ParanoidModel {
|
|||||||
},
|
},
|
||||||
]).findAll({
|
]).findAll({
|
||||||
where: {
|
where: {
|
||||||
|
teamId: user.teamId,
|
||||||
id: map(results, "id"),
|
id: map(results, "id"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
results: map(results, (result: any) => ({
|
results: map(results, (result: any) => ({
|
||||||
ranking: result.searchRanking,
|
ranking: result.searchRanking,
|
||||||
|
|||||||
Reference in New Issue
Block a user