mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Store lists as Sets
This commit is contained in:
parent
c7d39dd9f2
commit
1f5f47eab4
10 changed files with 30 additions and 38 deletions
|
|
@ -4,7 +4,7 @@ import { appsRelatedToVideo, videosRelatedToVideo, videosRelatedToApp } from './
|
|||
// import videoList from '~/static/video-list.json'
|
||||
|
||||
|
||||
export function buildVideoPayload ( video, allVideoAppsList, videoList ) {
|
||||
export function buildVideoPayload ( video, allVideoAppsList, videoListSet ) {
|
||||
// const { appsRelatedToVideo, videosRelatedToVideo } = await import('~/helpers/related.js')
|
||||
// const { default: videoList } = await import('~/static/video-list.json')
|
||||
|
||||
|
|
@ -15,18 +15,18 @@ export function buildVideoPayload ( video, allVideoAppsList, videoList ) {
|
|||
const featuredApps = appsRelatedToVideo( video, allVideoAppsList )
|
||||
|
||||
// Get related videos
|
||||
const relatedVideos = videosRelatedToVideo( video, allVideoAppsList, videoList )
|
||||
const relatedVideos = videosRelatedToVideo( video, allVideoAppsList, videoListSet )
|
||||
|
||||
return {
|
||||
video,
|
||||
featuredApps,
|
||||
// If no related video found just get the 12 newest ones
|
||||
relatedVideos: (relatedVideos.length !== 0) ? relatedVideos.slice(0, 24) : videoList.slice(0, 12)
|
||||
relatedVideos: (relatedVideos.length !== 0) ? relatedVideos.slice(0, 24) : Array.from(videoListSet).slice(0, 12)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function buildAppBenchmarkPayload ( app, allVideoAppsList, videoList ) {
|
||||
export function buildAppBenchmarkPayload ( app, allVideoAppsList, videoListSet ) {
|
||||
// const { allVideoAppsList } = await import('~/helpers/get-list.js')
|
||||
|
||||
// const { videosRelatedToApp } = await import('~/helpers/related.js')
|
||||
|
|
@ -39,7 +39,7 @@ export function buildAppBenchmarkPayload ( app, allVideoAppsList, videoList ) {
|
|||
|
||||
// const featuredApps = []
|
||||
|
||||
const relatedVideos = videosRelatedToApp( app, videoList ).map(video => {
|
||||
const relatedVideos = videosRelatedToApp( app, videoListSet ).map(video => {
|
||||
// console.log('video', video)
|
||||
return {
|
||||
...video,
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ export const allList = [
|
|||
]
|
||||
|
||||
|
||||
export function makeAppSearchLinks ( app, videoList ) {
|
||||
export function makeAppSearchLinks ( app, videoListSet ) {
|
||||
|
||||
const videos = videosRelatedToApp( app, videoList )
|
||||
const videos = videosRelatedToApp( app, videoListSet )
|
||||
|
||||
// If there are no videos
|
||||
// then skip
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export function appsRelatedToVideo ( video, allVideoAppsList ) {
|
|||
return relatedApps
|
||||
}
|
||||
|
||||
export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
|
||||
export function videosRelatedToVideo ( video, allVideoAppsList, videoListSet ) {
|
||||
const relatedVideos = {}
|
||||
|
||||
// console.log('videoList', videoList[0])
|
||||
|
|
@ -30,7 +30,7 @@ export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
|
|||
const featuredApps = appsRelatedToVideo( video, allVideoAppsList )
|
||||
|
||||
// Find other videos that also feature this video's app
|
||||
for (const otherVideo of videoList) {
|
||||
for (const otherVideo of videoListSet) {
|
||||
for (const app of featuredApps) {
|
||||
// console.log('otherVideo', otherVideo)
|
||||
// Skip if this app is not in the other video's apps
|
||||
|
|
@ -48,12 +48,14 @@ export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
|
|||
}
|
||||
|
||||
|
||||
export function videosRelatedToApp ( app, videoList ) {
|
||||
export function videosRelatedToApp ( app, videoListSet ) {
|
||||
|
||||
// console.log('videoListSet', videoListSet)
|
||||
|
||||
const relatedVideos = {}
|
||||
|
||||
// Find other videos that also feature this video's app
|
||||
for (const video of videoList) {
|
||||
for (const video of videoListSet) {
|
||||
if (!video.apps.includes(app.slug)) continue
|
||||
|
||||
relatedVideos[video.id] = video
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue