Use set for video app list

This commit is contained in:
Sam Carlton 2021-01-25 12:46:33 -06:00
parent bacbb825c6
commit 3a2326baa9
3 changed files with 19 additions and 22 deletions

View file

@ -29,7 +29,7 @@ class BuildLists {
// Where Eleventy Enpoints get stored
this.eleventyEndpointsSet = new Set()
this.allVideoAppsList = []
this.allVideoAppsList = new Set()
}
listsOptions = [
@ -102,15 +102,10 @@ class BuildLists {
]
getAllVideoAppsList = () => {
// return new Set([
// ...this.lists.apps,
// ...this.lists.games,
// ])
return [
...Array.from(this.lists.app),
...Array.from(this.lists.game),
]
return new Set([
...this.lists.app,
...this.lists.game,
])
}
saveToJson = async function ( content, path ) {

View file

@ -4,7 +4,7 @@ import { appsRelatedToVideo, videosRelatedToVideo, videosRelatedToApp } from './
// import videoList from '~/static/video-list.json'
export function buildVideoPayload ( video, allVideoAppsList, videoListSet ) {
export function buildVideoPayload ( video, allVideoAppsListSet, videoListSet ) {
// const { appsRelatedToVideo, videosRelatedToVideo } = await import('~/helpers/related.js')
// const { default: videoList } = await import('~/static/video-list.json')
@ -12,10 +12,10 @@ export function buildVideoPayload ( video, allVideoAppsList, videoListSet ) {
// const video = videoList.find(video => (video.slug === slug))
// Get featured apps
const featuredApps = appsRelatedToVideo( video, allVideoAppsList )
const featuredApps = appsRelatedToVideo( video, allVideoAppsListSet )
// Get related videos
const relatedVideos = videosRelatedToVideo( video, allVideoAppsList, videoListSet )
const relatedVideos = videosRelatedToVideo( video, allVideoAppsListSet, videoListSet )
return {
video,
@ -26,12 +26,12 @@ export function buildVideoPayload ( video, allVideoAppsList, videoListSet ) {
}
export function buildAppBenchmarkPayload ( app, allVideoAppsList, videoListSet ) {
// const { allVideoAppsList } = await import('~/helpers/get-list.js')
export function buildAppBenchmarkPayload ( app, allVideoAppsListSet, videoListSet ) {
// const { allVideoAppsListSet } = await import('~/helpers/get-list.js')
// const { videosRelatedToApp } = await import('~/helpers/related.js')
// const app = allVideoAppsList.find(app => (app.slug === slug))
// const app = allVideoAppsListSet.find(app => (app.slug === slug))
const submitVideoCard = {
endpoint: `https://docs.google.com/forms/d/e/1FAIpQLSeEVGM9vE7VcfLMy6fJkfU70X2VZ60rHDyhDQLtnAN4nso0WA/viewform?usp=pp_url&entry.1018125313=${app.name}`

View file

@ -1,15 +1,17 @@
// import { allVideoAppsList } from '~/helpers/get-list.js'
// import { allVideoAppsListSet } from '~/helpers/get-list.js'
// import videoList from '~/static/video-list.json'
export function matchesWholeWord (needle, haystack) {
return new RegExp('\\b' + needle + '\\b').test(haystack)
}
export function appsRelatedToVideo ( video, allVideoAppsList ) {
export function appsRelatedToVideo ( video, allVideoAppsListSet ) {
// console.log('allVideoAppsListSet', allVideoAppsListSet.length)
const relatedApps = []
// Find the apps listed in this video
for (const app of allVideoAppsList) {
for (const app of allVideoAppsListSet) {
// console.log('video', video)
// Skip this app if it's not listed in the videos apps
if (!video.apps.includes(app.slug)) continue
@ -21,13 +23,13 @@ export function appsRelatedToVideo ( video, allVideoAppsList ) {
return relatedApps
}
export function videosRelatedToVideo ( video, allVideoAppsList, videoListSet ) {
export function videosRelatedToVideo ( video, allVideoAppsListSet, videoListSet ) {
const relatedVideos = {}
// console.log('videoList', videoList[0])
// console.log('allVideoAppsList', allVideoAppsList[0])
// console.log('allVideoAppsListSet', allVideoAppsListSet[0])
const featuredApps = appsRelatedToVideo( video, allVideoAppsList )
const featuredApps = appsRelatedToVideo( video, allVideoAppsListSet )
// Find other videos that also feature this video's app
for (const otherVideo of videoListSet) {