fix: Drafts appear in document insert search (#1148)

* fix: Drafts appear in document insert search

* test
This commit is contained in:
Tom Moor
2020-01-05 17:24:57 -08:00
committed by GitHub
parent 9214be5645
commit 0ccbc6126b
5 changed files with 49 additions and 5 deletions

View File

@ -244,6 +244,7 @@ type SearchOptions = {
dateFilter?: 'day' | 'week' | 'month' | 'year',
collaboratorIds?: string[],
includeArchived?: boolean,
includeDrafts?: boolean,
};
Document.searchForTeam = async (
@ -351,7 +352,11 @@ Document.searchForUser = async (
}
${options.includeArchived ? '' : '"archivedAt" IS NULL AND'}
"deletedAt" IS NULL AND
("publishedAt" IS NOT NULL OR "createdById" = :userId)
${
options.includeDrafts
? '("publishedAt" IS NOT NULL OR "createdById" = :userId)'
: '"publishedAt" IS NOT NULL'
}
ORDER BY
"searchRanking" DESC,
"updatedAt" DESC