forked from DebaucheryLibrarian/traxxx
Removed type property from scenes API.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const config = require('config');
|
||||
|
||||
const logger = require('./logger')(__filename);
|
||||
@@ -85,6 +86,9 @@ async function fetchChannelsFromArgv() {
|
||||
}
|
||||
|
||||
async function fetchChannelsFromConfig() {
|
||||
console.log(config.include);
|
||||
|
||||
/*
|
||||
const rawNetworks = await knex.raw(`
|
||||
WITH RECURSIVE children AS (
|
||||
SELECT
|
||||
@@ -125,8 +129,71 @@ async function fetchChannelsFromConfig() {
|
||||
config.include.networks,
|
||||
config.exclude.networks,
|
||||
]);
|
||||
*/
|
||||
|
||||
console.log(rawNetworks.rows);
|
||||
const rawNetworks = await knex.raw(`
|
||||
/* select channels associated to configured networks */
|
||||
WITH RECURSIVE channels AS (
|
||||
/* select configured networks */
|
||||
SELECT
|
||||
id, parent_id, name, type, slug
|
||||
FROM
|
||||
entities
|
||||
WHERE
|
||||
(slug = ANY(:includeNetworks)
|
||||
AND NOT entities.slug = ANY(:excludedNetworks))
|
||||
AND entities.type = 'network'
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* select recursive children of configured networks */
|
||||
SELECT
|
||||
entities.id, entities.parent_id, entities.name, entities.type, entities.slug
|
||||
FROM
|
||||
entities
|
||||
INNER JOIN
|
||||
channels ON channels.id = entities.parent_id
|
||||
WHERE
|
||||
NOT (
|
||||
(entities.slug = ANY(:excludedNetworks) AND entities.type = 'network')
|
||||
OR (entities.slug = ANY(:excludedChannels) AND entities.type = 'channel')
|
||||
)
|
||||
)
|
||||
/* select recursive channels as children of networks */
|
||||
SELECT
|
||||
entities.*, json_agg(channels) as children
|
||||
FROM
|
||||
channels
|
||||
LEFT JOIN
|
||||
entities ON entities.id = channels.parent_id
|
||||
WHERE
|
||||
channels.type = 'channel'
|
||||
GROUP BY
|
||||
entities.id
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* select configured channels as children of networks */
|
||||
SELECT
|
||||
entities.*, json_agg(children) as children
|
||||
FROM
|
||||
entities AS children
|
||||
LEFT JOIN
|
||||
entities ON entities.id = children.parent_id
|
||||
WHERE
|
||||
children.slug = ANY(:includedChannels)
|
||||
AND
|
||||
children.type = 'channel'
|
||||
GROUP BY
|
||||
entities.id
|
||||
`, {
|
||||
includedNetworks: config.include.networks,
|
||||
includedChannels: config.include.channels,
|
||||
excludedNetworks: config.exclude.networks,
|
||||
excludedChannels: config.exclude.channels,
|
||||
});
|
||||
|
||||
console.log(util.inspect(rawNetworks.rows, null, null));
|
||||
|
||||
/*
|
||||
const curatedSites = await curateEntities(rawChannels, true);
|
||||
|
||||
Reference in New Issue
Block a user