forked from DebaucheryLibrarian/traxxx
Switched to tabs. Adding missing actor entries when scraping actors, with batch ID.
This commit is contained in:
@@ -3,29 +3,29 @@
|
||||
const { fetchActors } = require('../actors');
|
||||
|
||||
async function fetchActorsApi(req, res) {
|
||||
const actorId = typeof req.params.actorId === 'number' ? req.params.actorId : null;
|
||||
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
|
||||
const actorId = typeof req.params.actorId === 'number' ? req.params.actorId : null;
|
||||
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
|
||||
|
||||
if (actorId || actorSlug) {
|
||||
const actors = await fetchActors({
|
||||
id: actorId,
|
||||
slug: actorSlug,
|
||||
});
|
||||
if (actorId || actorSlug) {
|
||||
const actors = await fetchActors({
|
||||
id: actorId,
|
||||
slug: actorSlug,
|
||||
});
|
||||
|
||||
if (actors.length > 0) {
|
||||
res.send(actors[0]);
|
||||
return;
|
||||
}
|
||||
if (actors.length > 0) {
|
||||
res.send(actors[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
res.status(404).send();
|
||||
return;
|
||||
}
|
||||
res.status(404).send();
|
||||
return;
|
||||
}
|
||||
|
||||
const actors = await fetchActors(null, req.query.limit);
|
||||
const actors = await fetchActors(null, req.query.limit);
|
||||
|
||||
res.send(actors);
|
||||
res.send(actors);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchActors: fetchActorsApi,
|
||||
fetchActors: fetchActorsApi,
|
||||
};
|
||||
|
||||
@@ -3,24 +3,24 @@
|
||||
const { fetchNetworks, fetchNetworksFromReleases } = require('../networks');
|
||||
|
||||
async function fetchNetworksApi(req, res) {
|
||||
const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : undefined; // null will literally include NULL results
|
||||
const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : undefined;
|
||||
const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : undefined; // null will literally include NULL results
|
||||
const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : undefined;
|
||||
|
||||
const networks = await fetchNetworks({
|
||||
id: networkId,
|
||||
slug: networkSlug,
|
||||
});
|
||||
const networks = await fetchNetworks({
|
||||
id: networkId,
|
||||
slug: networkSlug,
|
||||
});
|
||||
|
||||
res.send(networks);
|
||||
res.send(networks);
|
||||
}
|
||||
|
||||
async function fetchNetworksFromReleasesApi(req, res) {
|
||||
const networks = await fetchNetworksFromReleases();
|
||||
const networks = await fetchNetworksFromReleases();
|
||||
|
||||
res.send(networks);
|
||||
res.send(networks);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchNetworks: fetchNetworksApi,
|
||||
fetchNetworksFromReleases: fetchNetworksFromReleasesApi,
|
||||
fetchNetworks: fetchNetworksApi,
|
||||
fetchNetworksFromReleases: fetchNetworksFromReleasesApi,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ const moment = require('moment');
|
||||
const { cmToFeetInches, kgToLbs } = require('../../utils/convert');
|
||||
|
||||
const schemaExtender = makeExtendSchemaPlugin(_build => ({
|
||||
typeDefs: gql`
|
||||
typeDefs: gql`
|
||||
enum Units {
|
||||
METRIC
|
||||
IMPERIAL
|
||||
@@ -17,32 +17,32 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({
|
||||
weight(units:Units): String @requires(columns: ["weight"])
|
||||
}
|
||||
`,
|
||||
resolvers: {
|
||||
Actor: {
|
||||
age(parent, _args, _context, _info) {
|
||||
if (!parent.birthdate) return null;
|
||||
resolvers: {
|
||||
Actor: {
|
||||
age(parent, _args, _context, _info) {
|
||||
if (!parent.birthdate) return null;
|
||||
|
||||
return moment().diff(parent.birthdate, 'years');
|
||||
},
|
||||
height(parent, args, _context, _info) {
|
||||
if (!parent.height) return null;
|
||||
return moment().diff(parent.birthdate, 'years');
|
||||
},
|
||||
height(parent, args, _context, _info) {
|
||||
if (!parent.height) return null;
|
||||
|
||||
if (args.units === 'IMPERIAL') {
|
||||
const { feet, inches } = cmToFeetInches(parent.height);
|
||||
return `${feet}' ${inches}"`;
|
||||
}
|
||||
if (args.units === 'IMPERIAL') {
|
||||
const { feet, inches } = cmToFeetInches(parent.height);
|
||||
return `${feet}' ${inches}"`;
|
||||
}
|
||||
|
||||
return parent.height.toString();
|
||||
},
|
||||
weight(parent, args, _context, _info) {
|
||||
if (!parent.weight) return null;
|
||||
return parent.height.toString();
|
||||
},
|
||||
weight(parent, args, _context, _info) {
|
||||
if (!parent.weight) return null;
|
||||
|
||||
return args.units === 'IMPERIAL'
|
||||
? kgToLbs(parent.weight).toString()
|
||||
: parent.weight.toString();
|
||||
},
|
||||
},
|
||||
},
|
||||
return args.units === 'IMPERIAL'
|
||||
? kgToLbs(parent.weight).toString()
|
||||
: parent.weight.toString();
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
module.exports = [schemaExtender];
|
||||
|
||||
@@ -5,7 +5,7 @@ const SitePlugins = require('./sites');
|
||||
// const ReleasePlugins = require('./releases');
|
||||
|
||||
module.exports = {
|
||||
ActorPlugins,
|
||||
SitePlugins,
|
||||
ReleasePlugins: [],
|
||||
ActorPlugins,
|
||||
SitePlugins,
|
||||
ReleasePlugins: [],
|
||||
};
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
const { makeExtendSchemaPlugin, gql } = require('graphile-utils');
|
||||
|
||||
const schemaExtender = makeExtendSchemaPlugin(_build => ({
|
||||
typeDefs: gql`
|
||||
typeDefs: gql`
|
||||
extend type Release {}
|
||||
`,
|
||||
resolvers: {
|
||||
Release: {
|
||||
async foo(_parent, _args, _context, _info) {
|
||||
// template
|
||||
},
|
||||
},
|
||||
},
|
||||
resolvers: {
|
||||
Release: {
|
||||
async foo(_parent, _args, _context, _info) {
|
||||
// template
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
module.exports = [schemaExtender];
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
const { makeExtendSchemaPlugin, gql } = require('graphile-utils');
|
||||
|
||||
const schemaExtender = makeExtendSchemaPlugin(_build => ({
|
||||
typeDefs: gql`
|
||||
typeDefs: gql`
|
||||
extend type Site {
|
||||
independent: Boolean @requires(columns: ["parameters"])
|
||||
}
|
||||
`,
|
||||
resolvers: {
|
||||
Site: {
|
||||
independent(parent, _args, _context, _info) {
|
||||
return !!parent.parameters?.independent;
|
||||
},
|
||||
},
|
||||
},
|
||||
resolvers: {
|
||||
Site: {
|
||||
independent(parent, _args, _context, _info) {
|
||||
return !!parent.parameters?.independent;
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
module.exports = [schemaExtender];
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
const { fetchReleases, searchReleases } = require('../releases');
|
||||
|
||||
async function fetchReleasesApi(req, res) {
|
||||
const query = req.query.query || req.query.q;
|
||||
const query = req.query.query || req.query.q;
|
||||
|
||||
const releases = query
|
||||
? await searchReleases(query, req.query.limit)
|
||||
: await fetchReleases(req.query.limit);
|
||||
const releases = query
|
||||
? await searchReleases(query, req.query.limit)
|
||||
: await fetchReleases(req.query.limit);
|
||||
|
||||
res.send(releases);
|
||||
res.send(releases);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchReleases: fetchReleasesApi,
|
||||
fetchReleases: fetchReleasesApi,
|
||||
};
|
||||
|
||||
@@ -15,68 +15,68 @@ const logger = require('../logger')(__filename);
|
||||
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
||||
|
||||
const {
|
||||
fetchReleases,
|
||||
fetchReleases,
|
||||
} = require('./releases');
|
||||
|
||||
function initServer() {
|
||||
const app = express();
|
||||
const router = Router();
|
||||
const app = express();
|
||||
const router = Router();
|
||||
|
||||
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
||||
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
||||
|
||||
app.use(postgraphile(
|
||||
connectionString,
|
||||
'public',
|
||||
{
|
||||
// watchPg: true,
|
||||
dynamicJson: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain: () => true,
|
||||
simpleCollections: 'only',
|
||||
graphileBuildOptions: {
|
||||
pgOmitListSuffix: true,
|
||||
connectionFilterRelations: true,
|
||||
},
|
||||
appendPlugins: [
|
||||
PgSimplifyInflectorPlugin,
|
||||
PgConnectionFilterPlugin,
|
||||
PgOrderByRelatedPlugin,
|
||||
...ActorPlugins,
|
||||
...SitePlugins,
|
||||
...ReleasePlugins,
|
||||
],
|
||||
},
|
||||
));
|
||||
app.use(postgraphile(
|
||||
connectionString,
|
||||
'public',
|
||||
{
|
||||
// watchPg: true,
|
||||
dynamicJson: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain: () => true,
|
||||
simpleCollections: 'only',
|
||||
graphileBuildOptions: {
|
||||
pgOmitListSuffix: true,
|
||||
connectionFilterRelations: true,
|
||||
},
|
||||
appendPlugins: [
|
||||
PgSimplifyInflectorPlugin,
|
||||
PgConnectionFilterPlugin,
|
||||
PgOrderByRelatedPlugin,
|
||||
...ActorPlugins,
|
||||
...SitePlugins,
|
||||
...ReleasePlugins,
|
||||
],
|
||||
},
|
||||
));
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
router.use('/media', express.static(config.media.path));
|
||||
router.use(express.static('public'));
|
||||
router.use('/media', express.static(config.media.path));
|
||||
router.use(express.static('public'));
|
||||
|
||||
router.use('/img', (req, res) => {
|
||||
res.status(404).send();
|
||||
});
|
||||
router.use('/img', (req, res) => {
|
||||
res.status(404).send();
|
||||
});
|
||||
|
||||
router.use(bodyParser.json({ strict: false }));
|
||||
router.use(bodyParser.json({ strict: false }));
|
||||
|
||||
router.get('/api/releases', fetchReleases);
|
||||
router.get('/api/releases', fetchReleases);
|
||||
|
||||
router.get('*', (req, res) => {
|
||||
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
||||
env: JSON.stringify({
|
||||
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
||||
}),
|
||||
});
|
||||
});
|
||||
router.get('*', (req, res) => {
|
||||
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
||||
env: JSON.stringify({
|
||||
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
app.use(router);
|
||||
app.use(router);
|
||||
|
||||
const server = app.listen(config.web.port, config.web.host, () => {
|
||||
const { address, port } = server.address();
|
||||
const server = app.listen(config.web.port, config.web.host, () => {
|
||||
const { address, port } = server.address();
|
||||
|
||||
logger.info(`Web server listening on ${address}:${port}`);
|
||||
});
|
||||
logger.info(`Web server listening on ${address}:${port}`);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = initServer;
|
||||
|
||||
@@ -3,24 +3,24 @@
|
||||
const { fetchSites, fetchSitesFromReleases } = require('../sites');
|
||||
|
||||
async function fetchSitesApi(req, res) {
|
||||
const siteId = typeof req.params.siteId === 'number' ? req.params.siteId : undefined;
|
||||
const siteSlug = typeof req.params.siteId === 'string' ? req.params.siteId : undefined;
|
||||
const siteId = typeof req.params.siteId === 'number' ? req.params.siteId : undefined;
|
||||
const siteSlug = typeof req.params.siteId === 'string' ? req.params.siteId : undefined;
|
||||
|
||||
const sites = await fetchSites({
|
||||
id: siteId,
|
||||
slug: siteSlug,
|
||||
});
|
||||
const sites = await fetchSites({
|
||||
id: siteId,
|
||||
slug: siteSlug,
|
||||
});
|
||||
|
||||
res.send(sites);
|
||||
res.send(sites);
|
||||
}
|
||||
|
||||
async function fetchSitesFromReleasesApi(req, res) {
|
||||
const sites = await fetchSitesFromReleases();
|
||||
const sites = await fetchSitesFromReleases();
|
||||
|
||||
res.send(sites);
|
||||
res.send(sites);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchSites: fetchSitesApi,
|
||||
fetchSitesFromReleases: fetchSitesFromReleasesApi,
|
||||
fetchSites: fetchSitesApi,
|
||||
fetchSitesFromReleases: fetchSitesFromReleasesApi,
|
||||
};
|
||||
|
||||
@@ -3,38 +3,38 @@
|
||||
const { fetchTags } = require('../tags');
|
||||
|
||||
async function fetchTagsApi(req, res) {
|
||||
const tagId = typeof req.params.tagId === 'number' ? req.params.tagId : undefined; // null will literally include NULL results
|
||||
const tagSlug = typeof req.params.tagId === 'string' ? req.params.tagId : undefined;
|
||||
const tagId = typeof req.params.tagId === 'number' ? req.params.tagId : undefined; // null will literally include NULL results
|
||||
const tagSlug = typeof req.params.tagId === 'string' ? req.params.tagId : undefined;
|
||||
|
||||
if (tagId || tagSlug) {
|
||||
const tags = await fetchTags({
|
||||
id: tagId,
|
||||
slug: tagSlug,
|
||||
}, null, req.query.limit);
|
||||
if (tagId || tagSlug) {
|
||||
const tags = await fetchTags({
|
||||
id: tagId,
|
||||
slug: tagSlug,
|
||||
}, null, req.query.limit);
|
||||
|
||||
if (tags.length > 0) {
|
||||
res.send(tags[0]);
|
||||
return;
|
||||
}
|
||||
if (tags.length > 0) {
|
||||
res.send(tags[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
res.status(404).send();
|
||||
return;
|
||||
}
|
||||
res.status(404).send();
|
||||
return;
|
||||
}
|
||||
|
||||
const query = {};
|
||||
const groupsQuery = {};
|
||||
const query = {};
|
||||
const groupsQuery = {};
|
||||
|
||||
if (req.query.priority) query.priority = req.query.priority.split(',');
|
||||
if (req.query.slug) query.slug = req.query.slug.split(',');
|
||||
if (req.query.group) {
|
||||
groupsQuery.slug = req.query.group.split(',');
|
||||
}
|
||||
if (req.query.priority) query.priority = req.query.priority.split(',');
|
||||
if (req.query.slug) query.slug = req.query.slug.split(',');
|
||||
if (req.query.group) {
|
||||
groupsQuery.slug = req.query.group.split(',');
|
||||
}
|
||||
|
||||
const tags = await fetchTags(query, groupsQuery, req.query.limit);
|
||||
const tags = await fetchTags(query, groupsQuery, req.query.limit);
|
||||
|
||||
res.send(tags);
|
||||
res.send(tags);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchTags: fetchTagsApi,
|
||||
fetchTags: fetchTagsApi,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user