refactor: remove redundant code
This commit is contained in:
parent
617f580318
commit
5003d1b0fd
|
@ -1,48 +0,0 @@
|
|||
import { LPE } from '../../../types/lpe.types'
|
||||
import { UnbodyHelpers } from '../unbody.helpers'
|
||||
import { UnbodyResSearchGoogleDocData } from '../unbody.types'
|
||||
import { UnbodyDataTypeConfig } from './types'
|
||||
|
||||
export const PostSearchResultDataType: UnbodyDataTypeConfig<
|
||||
UnbodyResSearchGoogleDocData,
|
||||
LPE.Search.ResultItem,
|
||||
UnbodyResSearchGoogleDocData,
|
||||
undefined,
|
||||
{
|
||||
query: string
|
||||
tags: string[]
|
||||
shows: LPE.Podcast.Show[]
|
||||
}
|
||||
> = {
|
||||
key: 'PostSearchResultDocument',
|
||||
objectType: 'GoogleDoc',
|
||||
classes: ['article', 'episode', 'search'],
|
||||
|
||||
isMatch: (helpers, data, original, root) =>
|
||||
data.__typename === 'GoogleDoc' && !root,
|
||||
|
||||
transform: async (helpers, data, original, root, context) => {
|
||||
const { query = '', tags = [] } = context ?? {}
|
||||
|
||||
const score =
|
||||
data.__typename === 'GoogleDoc'
|
||||
? UnbodyHelpers.resolveScore(data._additional)
|
||||
: query.length > 0 || tags.length > 0
|
||||
? data._additional.certainty
|
||||
: 0
|
||||
|
||||
const transformers = helpers.dataTypes.get({ objectType: 'GoogleDoc' })
|
||||
const transformed = await helpers.dataTypes.transform<LPE.Post.Document>(
|
||||
transformers,
|
||||
data,
|
||||
undefined,
|
||||
{ ...context },
|
||||
)
|
||||
|
||||
return {
|
||||
score,
|
||||
data: transformed,
|
||||
type: transformed.type,
|
||||
}
|
||||
},
|
||||
}
|
|
@ -6,7 +6,6 @@ import { ImageBlockDataType } from './ImageBlock.dataType'
|
|||
import { PodcastEpisodeDataType } from './PodcastEpisodeDocument.dataType'
|
||||
import { PodcastShowDataType } from './PodcastShowDocument.dataType'
|
||||
import { StaticPageDataType } from './StaticPageDocument.dataType'
|
||||
import { PostSearchResultDataType } from './PostSearchResult.dataType'
|
||||
import { TextBlockDataType } from './TextBlock.dataType'
|
||||
import { UnbodyDataTypes } from './UnbodyDataTypes'
|
||||
|
||||
|
@ -20,5 +19,4 @@ export const unbodyDataTypes = new UnbodyDataTypes([
|
|||
PodcastShowDataType,
|
||||
PodcastEpisodeDataType,
|
||||
StaticPageDataType,
|
||||
PostSearchResultDataType,
|
||||
])
|
||||
|
|
|
@ -50,7 +50,6 @@ export const UnbodyDataTypeKeys = {
|
|||
PodcastShowDocument: 'PodcastShowDocument',
|
||||
PodcastEpisodeDocument: 'PodcastEpisodeDocument',
|
||||
StaticPageDocument: 'StaticPageDocument',
|
||||
PostSearchResultDocument: 'PostSearchResultDocument',
|
||||
} as const
|
||||
|
||||
export type UnbodyDataTypeKey =
|
||||
|
|
Loading…
Reference in New Issue