Added prefixes for studio and info types, fixing studio identified as channel from URL.

This commit is contained in:
DebaucheryLibrarian 2024-07-09 00:07:22 +02:00
parent 0fdb9559f9
commit 38c7487ccc
1 changed files with 8 additions and 1 deletions

View File

@ -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');
}