mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #1977 from omnivore-app/fix/wordsCount
Add wordsCount if undefined when creating pages in elastic
This commit is contained in:
commit
9bc76b3c00
2 changed files with 6 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ import { ResponseError } from '@elastic/elasticsearch/lib/errors'
|
|||
import { BuiltQuery, ESBuilder, esBuilder } from 'elastic-ts'
|
||||
import { EntityType } from '../datalayer/pubsub'
|
||||
import { BulkActionType } from '../generated/graphql'
|
||||
import { wordsCount } from '../utils/helpers'
|
||||
import {
|
||||
DateFilter,
|
||||
FieldFilter,
|
||||
|
|
@ -245,6 +246,7 @@ export const createPage = async (
|
|||
...page,
|
||||
updatedAt: new Date(),
|
||||
savedAt: new Date(),
|
||||
wordsCount: page.wordsCount ?? wordsCount(page.content),
|
||||
},
|
||||
refresh: 'wait_for', // wait for the index to be refreshed before returning
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { createTestUser, deleteTestUser } from '../db'
|
||||
import { graphqlRequest, request } from '../util'
|
||||
import { expect } from 'chai'
|
||||
import 'mocha'
|
||||
import { User } from '../../src/entity/user'
|
||||
import { getPageByParam } from '../../src/elastic/pages'
|
||||
import { User } from '../../src/entity/user'
|
||||
import { createTestUser, deleteTestUser } from '../db'
|
||||
import { graphqlRequest, request } from '../util'
|
||||
|
||||
describe('PopularReads API', () => {
|
||||
let user: User
|
||||
|
|
@ -55,6 +55,7 @@ describe('PopularReads API', () => {
|
|||
expect(page?.url).to.eq(
|
||||
'https://blog.omnivore.app/p/getting-started-with-omnivore'
|
||||
)
|
||||
expect(page?.wordsCount).to.eq(1155)
|
||||
})
|
||||
|
||||
it('responds status code 500 when invalid user', async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue