Merge pull request #850 from omnivore-app/fix/search-result-is-read
Fix search by is:read or is:unread getting empty result by using the correct property name
This commit is contained in:
@ -48,8 +48,8 @@ const appendReadFilter = (body: SearchBody, filter: ReadFilter): void => {
|
||||
case ReadFilter.UNREAD:
|
||||
body.query.bool.filter.push({
|
||||
range: {
|
||||
readingProgress: {
|
||||
gte: 98,
|
||||
readingProgressPercent: {
|
||||
lt: 98,
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -57,8 +57,8 @@ const appendReadFilter = (body: SearchBody, filter: ReadFilter): void => {
|
||||
case ReadFilter.READ:
|
||||
body.query.bool.filter.push({
|
||||
range: {
|
||||
readingProgress: {
|
||||
lt: 98,
|
||||
readingProgressPercent: {
|
||||
gte: 98,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -14,7 +14,7 @@ export interface SearchBody {
|
||||
| { exists: { field: string } }
|
||||
| {
|
||||
range: {
|
||||
readingProgress: { gte: number } | { lt: number }
|
||||
readingProgressPercent: { gte: number } | { lt: number }
|
||||
}
|
||||
}
|
||||
| {
|
||||
|
||||
@ -1003,5 +1003,22 @@ describe('Article API', () => {
|
||||
expect(res.body.data.search.edges[4].node.id).to.eq(highlights[0].id)
|
||||
})
|
||||
})
|
||||
|
||||
context('when is:unread is in the query', () => {
|
||||
before(() => {
|
||||
keyword = 'search is:unread'
|
||||
})
|
||||
|
||||
it('should return unread articles in descending order', async () => {
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
|
||||
expect(res.body.data.search.edges.length).to.eq(5)
|
||||
expect(res.body.data.search.edges[0].node.id).to.eq(pages[4].id)
|
||||
expect(res.body.data.search.edges[1].node.id).to.eq(pages[3].id)
|
||||
expect(res.body.data.search.edges[2].node.id).to.eq(pages[2].id)
|
||||
expect(res.body.data.search.edges[3].node.id).to.eq(pages[1].id)
|
||||
expect(res.body.data.search.edges[4].node.id).to.eq(pages[0].id)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user