Added prefixes for studio and info types, fixing studio identified as channel from URL.
This commit is contained in:
@@ -4,6 +4,13 @@ import initLogger from './logger.js';
|
|||||||
|
|
||||||
const logger = initLogger();
|
const logger = initLogger();
|
||||||
|
|
||||||
|
const entityPrefixes = {
|
||||||
|
channel: '',
|
||||||
|
network: '_',
|
||||||
|
studio: '*',
|
||||||
|
info: '@',
|
||||||
|
};
|
||||||
|
|
||||||
export function curateEntity(entity, context) {
|
export function curateEntity(entity, context) {
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
return null;
|
return null;
|
||||||
@@ -136,7 +143,7 @@ export async function cacheEntityIds() {
|
|||||||
const entities = await knex('entities').select('id', 'slug', 'type');
|
const entities = await knex('entities').select('id', 'slug', 'type');
|
||||||
|
|
||||||
await redis.del('traxxx:entities:id_by_slug');
|
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');
|
logger.info('Cached entity IDs by slug');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user