diff options
-rw-r--r-- | src/data/cacheable-object.js | 24 | ||||
-rw-r--r-- | src/data/things.js | 4 | ||||
-rwxr-xr-x | src/upd8.js | 29 |
3 files changed, 55 insertions, 2 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js index fe1817f6..688d8a0f 100644 --- a/src/data/cacheable-object.js +++ b/src/data/cacheable-object.js @@ -315,6 +315,30 @@ export default class CacheableObject { }; } + static cacheAllExposedProperties(obj) { + if (!(obj instanceof CacheableObject)) { + console.warn('Not a CacheableObject:', obj); + return; + } + + if (!obj.constructor.propertyDescriptors) { + console.warn('Missing property descriptors:', obj); + return; + } + + for (const [property, descriptor] of Object.entries( + obj.constructor.propertyDescriptors + )) { + const {flags} = descriptor; + + if (!flags.expose) { + continue; + } + + obj[property]; + } + } + static DEBUG_SLOW_TRACK_INVALID_PROPERTIES = false; static _invalidAccesses = new Set(); diff --git a/src/data/things.js b/src/data/things.js index fa7a8d54..45cd7f2e 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -1071,7 +1071,7 @@ Artist.propertyDescriptors = { dependencies: ['trackData'], compute: ({trackData, [Artist.instance]: artist}) => - trackData.filter(({commentatorArtists}) => + trackData?.filter(({commentatorArtists}) => commentatorArtists?.includes(artist) ), }, @@ -1098,7 +1098,7 @@ Artist.propertyDescriptors = { dependencies: ['albumData'], compute: ({albumData, [Artist.instance]: artist}) => - albumData.filter(({commentatorArtists}) => + albumData?.filter(({commentatorArtists}) => commentatorArtists?.includes(artist) ), }, diff --git a/src/upd8.js b/src/upd8.js index 99d55374..0399b290 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -1703,6 +1703,19 @@ async function main() { type: 'flag', }, + // Compute ALL data properties before moving on to building. This ensures + // writes are processed at a stable speed (since they don't have to perform + // any additional data computation besides what is done for the page + // itself), but it'll also take a long while for the initial caching to + // complete. This shouldn't have any overall difference on efficiency as + // it's the same amount of processing being done regardless; the option is + // mostly present for optimization testing (i.e. if you want to focus on + // efficiency of data calculation or write generation separately instead of + // mixed together). + 'precache-data': { + type: 'flag', + }, + [parseOptions.handleUnknown]: () => {}, }); @@ -1742,6 +1755,7 @@ async function main() { const thumbsOnly = miscOptions['thumbs-only'] ?? false; const noBuild = miscOptions['no-build'] ?? false; const showAggregateTraces = miscOptions['show-traces'] ?? false; + const precacheData = miscOptions['precache-data'] ?? false; // NOT for ena8ling or disa8ling specific features of the site! // This is only in charge of what general groups of files to 8uild. @@ -1920,6 +1934,21 @@ async function main() { // which are only available after the initial linking. sortWikiDataArrays(wikiData); + if (precacheData) { + progressCallAll('Caching all data values', Object.entries(wikiData) + .filter(([key]) => + key !== 'listingSpec' && + key !== 'listingTargetSpec' && + key !== 'officialAlbumData' && + key !== 'fandomAlbumData') + .map(([key, value]) => + key === 'wikiInfo' ? [key, [value]] : + key === 'homepageLayout' ? [key, [value]] : + [key, value]) + .flatMap(([_key, things]) => things) + .map(thing => () => CacheableObject.cacheAllExposedProperties(thing))); + } + const internalDefaultLanguage = await processLanguageFile( path.join(__dirname, DEFAULT_STRINGS_FILE) ); |