Use simpler getRelatedVideos function

This commit is contained in:
Sam Carlton 2022-06-09 16:01:11 -05:00
parent 770af94ec2
commit dc27e091d2

View file

@ -17,7 +17,9 @@ import { saveSitemap } from '~/helpers/api/sitemap/build.js'
import { deviceSupportsApp } from '~/helpers/devices.js' import { deviceSupportsApp } from '~/helpers/devices.js'
import getListSummaryNumbers from '~/helpers/get-list-summary-numbers.js' import getListSummaryNumbers from '~/helpers/get-list-summary-numbers.js'
import { videosRelatedToApp } from '~/helpers/related.js' import {
getRelatedVideos
} from '~/helpers/related.js'
import { buildVideoPayload, buildAppBenchmarkPayload } from '~/helpers/build-payload.js' import { buildVideoPayload, buildAppBenchmarkPayload } from '~/helpers/build-payload.js'
import { import {
@ -164,7 +166,13 @@ class BuildLists {
shouldHaveRelatedVideos ( app ) { shouldHaveRelatedVideos ( app ) {
const appType = getAppType( app ) const appType = getAppType( app )
return appType === 'app' || appType === 'formula' const typeWithRelatedVideos = new Set([
'app',
'formula',
// 'video'
])
return typeWithRelatedVideos.has( appType )
} }
shouldHaveDeviceSupport ( app ) { shouldHaveDeviceSupport ( app ) {
@ -466,12 +474,10 @@ class BuildLists {
// Add related videos // Add related videos
if ( this.shouldHaveRelatedVideos( listEntry ) ) { if ( this.shouldHaveRelatedVideos( listEntry ) ) {
listEntry.relatedVideos = videosRelatedToApp( listEntry, this.lists.video ).map(video => { listEntry.relatedVideos = getRelatedVideos({
// console.log('video', video) listing: listEntry,
return { videoListSet: this.lists.video,
...video, appListSet: this.allVideoAppsList
endpoint: `${getAppEndpoint(listEntry)}/benchmarks#${video.id}`
}
}) })
} }
@ -520,6 +526,7 @@ class BuildLists {
const difference = getSymmetricDifference( listSlugs, fileNames ) const difference = getSymmetricDifference( listSlugs, fileNames )
console.log( 'List difference', difference ) console.log( 'List difference', difference )
console.log( `List difference Count ${ difference[0].length } / ${ difference[1].length }`, )
throw new Error( `Files (${ fileCount }) don\'t match list count in ${ apiListDirectory }(${ this.lists[listOptions.name].size }).` ) throw new Error( `Files (${ fileCount }) don\'t match list count in ${ apiListDirectory }(${ this.lists[listOptions.name].size }).` )
} }
@ -641,12 +648,10 @@ class BuildLists {
// Add standard app endpoint // Add standard app endpoint
if ( this.shouldHaveRelatedVideos( app ) ) { if ( this.shouldHaveRelatedVideos( app ) ) {
const relatedVideos = videosRelatedToApp( app, this.lists.video ).map(video => { const relatedVideos = getRelatedVideos({
// console.log('video', video) listing: app,
return { videoListSet: this.lists.video,
...video, appListSet: this.allVideoAppsList
endpoint: `${getAppEndpoint(app)}/benchmarks#${video.id}`
}
}) })
// Add app or formula endpoint // Add app or formula endpoint