From 38c7487ccc702cc88616e99341c994b7a1fc5ab6 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 9 Jul 2024 00:07:22 +0200 Subject: [PATCH] Added prefixes for studio and info types, fixing studio identified as channel from URL. --- src/entities.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/entities.js b/src/entities.js index 25d42ba..fed0a96 100644 --- a/src/entities.js +++ b/src/entities.js @@ -4,6 +4,13 @@ import initLogger from './logger.js'; const logger = initLogger(); +const entityPrefixes = { + channel: '', + network: '_', + studio: '*', + info: '@', +}; + export function curateEntity(entity, context) { if (!entity) { return null; @@ -136,7 +143,7 @@ export async function cacheEntityIds() { const entities = await knex('entities').select('id', 'slug', 'type'); await redis.del('traxxx:entities:id_by_slug'); - await redis.hSet('traxxx:entities:id_by_slug', entities.map((entity) => [entity.type === 'network' ? `_${entity.slug}` : entity.slug, entity.id])); + await redis.hSet('traxxx:entities:id_by_slug', entities.map((entity) => [`${entityPrefixes[entity.type]}${entity.slug}`, entity.id])); logger.info('Cached entity IDs by slug'); }