refactor: remove redundant code

This commit is contained in:
Hossein Mehrabi 2023-08-26 18:27:53 +03:30
parent 617f580318
commit 5003d1b0fd
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1
3 changed files with 0 additions and 51 deletions

View File

@ -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,
}
},
}

View File

@ -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,
])

View File

@ -50,7 +50,6 @@ export const UnbodyDataTypeKeys = {
PodcastShowDocument: 'PodcastShowDocument',
PodcastEpisodeDocument: 'PodcastEpisodeDocument',
StaticPageDocument: 'StaticPageDocument',
PostSearchResultDocument: 'PostSearchResultDocument',
} as const
export type UnbodyDataTypeKey =