forked from DebaucheryLibrarian/traxxx
Added prefer option for entity resolution. Merged migrations.
This commit is contained in:
@@ -199,7 +199,7 @@ async function fetchIncludedEntities() {
|
||||
return curatedNetworks;
|
||||
}
|
||||
|
||||
async function fetchEntitiesBySlug(entitySlugs, sort = 'asc') {
|
||||
async function fetchEntitiesBySlug(entitySlugs, prefer = 'channel') {
|
||||
const entities = await knex.raw(`
|
||||
WITH RECURSIVE entity_tree as (
|
||||
SELECT to_jsonb(entities) as entity,
|
||||
@@ -235,7 +235,7 @@ async function fetchEntitiesBySlug(entitySlugs, sort = 'asc') {
|
||||
`, {
|
||||
entitySlugs: entitySlugs.filter((slug) => !slug.includes('.')),
|
||||
entityHosts: entitySlugs.filter((slug) => slug.includes('.')).map((hostname) => `%${hostname}%`),
|
||||
sort: knex.raw(sort),
|
||||
sort: knex.raw(prefer === 'channel' ? 'asc' : 'desc'),
|
||||
});
|
||||
|
||||
// channel entity will overwrite network entity
|
||||
@@ -262,7 +262,7 @@ async function fetchReleaseEntities(baseReleases) {
|
||||
.filter(Boolean),
|
||||
));
|
||||
|
||||
return fetchEntitiesBySlug(entitySlugs, 'desc');
|
||||
return fetchEntitiesBySlug(entitySlugs, argv.prefer || 'network');
|
||||
}
|
||||
|
||||
async function fetchEntity(entityId, type) {
|
||||
|
||||
Reference in New Issue
Block a user