Improvements, GrapQL experiments. Fixed Babel dependencies.

This commit is contained in:
ThePendulum 2019-12-15 22:16:55 +01:00
parent 7ba716cd6f
commit 07a6c77ce2
9 changed files with 183 additions and 1898 deletions

View File

@ -39,7 +39,7 @@ async function post(endpoint, data) {
throw new Error(errorMsg); throw new Error(errorMsg);
} }
async function graphql(operationName, query, variables = null) { async function graphql(query, variables = null) {
const res = await fetch('/graphql', { const res = await fetch('/graphql', {
method: 'POST', method: 'POST',
mode: 'cors', mode: 'cors',
@ -48,7 +48,6 @@ async function graphql(operationName, query, variables = null) {
}, },
credentials: 'same-origin', credentials: 'same-origin',
body: JSON.stringify({ body: JSON.stringify({
operationName,
query, query,
variables, variables,
}), }),

View File

@ -1,4 +1,24 @@
import { get, graphql } from '../api'; import { graphql } from '../api';
function curateRelease(release) {
const curatedRelease = {
...release,
actors: release.actors.map(({ actor }) => ({
...actor,
avatar: actor.avatar[0],
origin: {
country: actor.originCountry,
},
})),
poster: release.poster[0],
network: release.site.network,
tags: release.tags.map(({ tag }) => tag),
};
if (release.trailer) [curatedRelease.trailer] = release.trailer;
return curatedRelease;
}
function initReleasesActions(_store, _router) { function initReleasesActions(_store, _router) {
async function fetchReleases({ _commit }) { async function fetchReleases({ _commit }) {
@ -10,8 +30,8 @@ function initReleasesActions(_store, _router) {
}); });
*/ */
const { releases } = await graphql('MyQuery', ` const { releases } = await graphql(`
query MyQuery { query Releases {
releases(orderBy: DATE_DESC) { releases(orderBy: DATE_DESC) {
id id
title title
@ -26,9 +46,11 @@ function initReleasesActions(_store, _router) {
id id
name name
slug slug
origin: countryByBirthCountryAlpha2 { birthdate
originCountry: countryByBirthCountryAlpha2 {
alpha2 alpha2
name name
alias
} }
avatar: actorsMediasByTargetId(condition: { role: "avatar" }) { avatar: actorsMediasByTargetId(condition: { role: "avatar" }) {
id id
@ -46,14 +68,6 @@ function initReleasesActions(_store, _router) {
thumbnail thumbnail
role role
} }
photos: releasesMediasByTargetId(condition: { role: "photos" }) {
mime
id
index
path
thumbnail
role
}
tags: releasesTagsByTargetId { tags: releasesTagsByTargetId {
tag { tag {
name name
@ -78,26 +92,93 @@ function initReleasesActions(_store, _router) {
} }
`); `);
const curatedReleases = releases.map(release => ({ return releases.map(release => curateRelease(release));
...release,
actors: release.actors.map(({ actor }) => ({
...actor,
avatar: actor.avatar[0],
})),
poster: release.poster[0],
network: release.site.network,
tags: release.tags.map(({ tag }) => tag),
}));
console.log(curatedReleases);
return curatedReleases;
} }
async function fetchReleaseById({ _commit }, releaseId) { async function fetchReleaseById({ _commit }, releaseId) {
const release = await get(`/releases/${releaseId}`); // const release = await get(`/releases/${releaseId}`);
return release; const { release } = await graphql(`
query Release($releaseId:Int!) {
release(id: $releaseId) {
id
title
description
date
duration
createdAt
shootId
url
actors: actorsAssociateds {
actor {
id
name
slug
birthdate
originCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
avatar: actorsMediasByTargetId(condition: { role: "avatar" }) {
id
thumbnail
path
mime
}
}
}
poster: releasesMediasByTargetId(condition: { role: "poster" }) {
mime
id
index
path
thumbnail
role
}
photos: releasesMediasByTargetId(condition: { role: "photo" }) {
mime
id
index
path
thumbnail
role
}
trailer: releasesMediasByTargetId(condition: { role: "trailer" }) {
mime
id
index
path
thumbnail
role
}
tags: releasesTagsByTargetId {
tag {
name
priority
slug
id
}
}
site {
id
name
slug
url
network {
id
name
slug
url
}
}
}
}
`, {
releaseId: Number(releaseId),
});
return curateRelease(release);
} }
return { return {

View File

@ -290,17 +290,17 @@ exports.up = knex => Promise.resolve()
table.unique(['domain', 'tag_id', 'target_id']); table.unique(['domain', 'tag_id', 'target_id']);
})) }))
.then(() => knex.raw(` .then(() => knex.raw(`
CREATE VIEW releases_media AS SELECT * FROM public.media WHERE domain = 'releases'; CREATE VIEW releases_media AS SELECT * FROM media WHERE domain = 'releases';
CREATE VIEW actors_media AS SELECT * FROM public.media WHERE domain = 'actors'; CREATE VIEW actors_media AS SELECT * FROM media WHERE domain = 'actors';
CREATE VIEW tags_media AS SELECT * FROM public.media WHERE domain = 'media'; CREATE VIEW tags_media AS SELECT * FROM media WHERE domain = 'media';
CREATE VIEW releases_tags AS SELECT * FROM public.tags_associated WHERE domain = 'releases'; CREATE VIEW releases_tags AS SELECT * FROM tags_associated WHERE domain = 'releases';
COMMENT ON VIEW releases_media IS E'@foreignKey (target_id) references releases (id)|@fieldName releaseId'; COMMENT ON VIEW releases_media IS E'@foreignKey (target_id) references releases (id)|@fieldName releaseMedia';
COMMENT ON VIEW actors_media IS E'@foreignKey (target_id) references actors (id)|@fieldName actorId'; COMMENT ON VIEW actors_media IS E'@foreignKey (target_id) references actors (id)|@fieldName actorMedia';
COMMENT ON VIEW tags_media IS E'@foreignKey (target_id) references tags (id)|@fieldName tagMediaId'; COMMENT ON VIEW tags_media IS E'@foreignKey (target_id) references tags (id)|@fieldName tagMedia';
COMMENT ON VIEW releases_tags IS E'@foreignKey (target_id) references releases (id)\n@foreignKey (tag_id) references tags (id)'; COMMENT ON VIEW releases_tags IS E'@foreignKey (target_id) references releases (id)\n@foreignKey (tag_id) references tags (id)|@fieldName releaseTags';
`)); `));
exports.down = knex => Promise.resolve() exports.down = knex => Promise.resolve()

459
package-lock.json generated
View File

@ -1277,22 +1277,21 @@
} }
}, },
"@babel/register": { "@babel/register": {
"version": "7.4.0", "version": "7.7.4",
"resolved": "https://registry.npmjs.org/@babel/register/-/register-7.4.0.tgz", "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.7.4.tgz",
"integrity": "sha512-ekziebXBnS/7V6xk8sBfLSSD6YZuy6P29igBtR6OL/tswKdxOV+Yqq0nzICMguVYtGRZYUCGpfGV8J9Za2iBdw==", "integrity": "sha512-/fmONZqL6ZMl9KJUYajetCrID6m0xmL4odX7v+Xvoxcv0DdbP/oO0TWIeLUCHqczQ6L6njDMqmqHFy2cp3FFsA==",
"requires": { "requires": {
"core-js": "^3.0.0",
"find-cache-dir": "^2.0.0", "find-cache-dir": "^2.0.0",
"lodash": "^4.17.11", "lodash": "^4.17.13",
"mkdirp": "^0.5.1", "make-dir": "^2.1.0",
"pirates": "^4.0.0", "pirates": "^4.0.0",
"source-map-support": "^0.5.9" "source-map-support": "^0.5.16"
}, },
"dependencies": { "dependencies": {
"core-js": { "lodash": {
"version": "3.0.1", "version": "4.17.15",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-sco40rF+2KlE0ROMvydjkrVMMG1vYilP2ALoRXcYR4obqbYIuV3Bg+51GEDW+HF8n7NRA+iaA4qD0nD9lo9mew==" "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
} }
} }
}, },
@ -2317,204 +2316,6 @@
"@babel/runtime-corejs3": "^7.7.4" "@babel/runtime-corejs3": "^7.7.4"
} }
}, },
"babel-cli": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-cli/-/babel-cli-6.26.0.tgz",
"integrity": "sha1-UCq1SHTX24itALiHoGODzgPQAvE=",
"dev": true,
"requires": {
"babel-core": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"chokidar": "^1.6.1",
"commander": "^2.11.0",
"convert-source-map": "^1.5.0",
"fs-readdir-recursive": "^1.0.0",
"glob": "^7.1.2",
"lodash": "^4.17.4",
"output-file-sync": "^1.1.2",
"path-is-absolute": "^1.0.1",
"slash": "^1.0.0",
"source-map": "^0.5.6",
"v8flags": "^2.1.1"
},
"dependencies": {
"anymatch": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz",
"integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==",
"dev": true,
"optional": true,
"requires": {
"micromatch": "^2.1.5",
"normalize-path": "^2.0.0"
}
},
"arr-diff": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
"integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
"dev": true,
"optional": true,
"requires": {
"arr-flatten": "^1.0.1"
}
},
"array-unique": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
"dev": true,
"optional": true
},
"braces": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
"integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
"dev": true,
"optional": true,
"requires": {
"expand-range": "^1.8.1",
"preserve": "^0.2.0",
"repeat-element": "^1.1.2"
}
},
"chokidar": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
"integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=",
"dev": true,
"optional": true,
"requires": {
"anymatch": "^1.3.0",
"async-each": "^1.0.0",
"fsevents": "^1.0.0",
"glob-parent": "^2.0.0",
"inherits": "^2.0.1",
"is-binary-path": "^1.0.0",
"is-glob": "^2.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.0.0"
}
},
"expand-brackets": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
"integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
"dev": true,
"optional": true,
"requires": {
"is-posix-bracket": "^0.1.0"
}
},
"extglob": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
"dev": true,
"optional": true,
"requires": {
"is-extglob": "^1.0.0"
}
},
"glob-parent": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz",
"integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
"dev": true,
"optional": true,
"requires": {
"is-glob": "^2.0.0"
}
},
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
"dev": true,
"optional": true
},
"is-glob": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"dev": true,
"optional": true,
"requires": {
"is-extglob": "^1.0.0"
}
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"optional": true,
"requires": {
"is-buffer": "^1.1.5"
}
},
"micromatch": {
"version": "2.3.11",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
"integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
"dev": true,
"optional": true,
"requires": {
"arr-diff": "^2.0.0",
"array-unique": "^0.2.1",
"braces": "^1.8.2",
"expand-brackets": "^0.1.4",
"extglob": "^0.3.1",
"filename-regex": "^2.0.0",
"is-extglob": "^1.0.0",
"is-glob": "^2.0.1",
"kind-of": "^3.0.2",
"normalize-path": "^2.0.1",
"object.omit": "^2.0.0",
"parse-glob": "^3.0.4",
"regex-cache": "^0.4.2"
}
},
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
"dev": true,
"optional": true,
"requires": {
"remove-trailing-separator": "^1.0.1"
}
},
"output-file-sync": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-1.1.2.tgz",
"integrity": "sha1-0KM+7+YaIF+suQCS6CZZjVJFznY=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.4",
"mkdirp": "^0.5.1",
"object-assign": "^4.1.0"
}
},
"slash": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
"integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=",
"dev": true
},
"v8flags": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz",
"integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=",
"dev": true,
"requires": {
"user-home": "^1.1.1"
}
}
}
},
"babel-code-frame": { "babel-code-frame": {
"version": "6.26.0", "version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@ -4976,62 +4777,6 @@
} }
} }
}, },
"expand-range": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz",
"integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=",
"dev": true,
"optional": true,
"requires": {
"fill-range": "^2.1.0"
},
"dependencies": {
"fill-range": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz",
"integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==",
"dev": true,
"optional": true,
"requires": {
"is-number": "^2.1.0",
"isobject": "^2.0.0",
"randomatic": "^3.0.0",
"repeat-element": "^1.1.2",
"repeat-string": "^1.5.2"
}
},
"is-number": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
"integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=",
"dev": true,
"optional": true,
"requires": {
"kind-of": "^3.0.2"
}
},
"isobject": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
"integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
"dev": true,
"optional": true,
"requires": {
"isarray": "1.0.0"
}
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"optional": true,
"requires": {
"is-buffer": "^1.1.5"
}
}
}
},
"expand-template": { "expand-template": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",
@ -5275,13 +5020,6 @@
"flat-cache": "^2.0.1" "flat-cache": "^2.0.1"
} }
}, },
"filename-regex": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
"integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=",
"dev": true,
"optional": true
},
"fill-range": { "fill-range": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
@ -6272,46 +6010,6 @@
"path-is-absolute": "^1.0.0" "path-is-absolute": "^1.0.0"
} }
}, },
"glob-base": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz",
"integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=",
"dev": true,
"optional": true,
"requires": {
"glob-parent": "^2.0.0",
"is-glob": "^2.0.0"
},
"dependencies": {
"glob-parent": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz",
"integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
"dev": true,
"optional": true,
"requires": {
"is-glob": "^2.0.0"
}
},
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
"dev": true,
"optional": true
},
"is-glob": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"dev": true,
"optional": true,
"requires": {
"is-extglob": "^1.0.0"
}
}
}
},
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
@ -7133,23 +6831,6 @@
"integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=",
"dev": true "dev": true
}, },
"is-dotfile": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz",
"integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=",
"dev": true,
"optional": true
},
"is-equal-shallow": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz",
"integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=",
"dev": true,
"optional": true,
"requires": {
"is-primitive": "^2.0.0"
}
},
"is-extendable": { "is-extendable": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
@ -7214,20 +6895,6 @@
"isobject": "^3.0.1" "isobject": "^3.0.1"
} }
}, },
"is-posix-bracket": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
"integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=",
"dev": true,
"optional": true
},
"is-primitive": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz",
"integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=",
"dev": true,
"optional": true
},
"is-promise": { "is-promise": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
@ -7889,13 +7556,6 @@
"object-visit": "^1.0.0" "object-visit": "^1.0.0"
} }
}, },
"math-random": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz",
"integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==",
"dev": true,
"optional": true
},
"md5.js": { "md5.js": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@ -8870,29 +8530,6 @@
"make-iterator": "^1.0.0" "make-iterator": "^1.0.0"
} }
}, },
"object.omit": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz",
"integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=",
"dev": true,
"optional": true,
"requires": {
"for-own": "^0.1.4",
"is-extendable": "^0.1.1"
},
"dependencies": {
"for-own": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz",
"integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=",
"dev": true,
"optional": true,
"requires": {
"for-in": "^1.0.1"
}
}
}
},
"object.pick": { "object.pick": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz",
@ -9090,38 +8727,6 @@
"path-root": "^0.1.1" "path-root": "^0.1.1"
} }
}, },
"parse-glob": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz",
"integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=",
"dev": true,
"optional": true,
"requires": {
"glob-base": "^0.3.0",
"is-dotfile": "^1.0.0",
"is-extglob": "^1.0.0",
"is-glob": "^2.0.0"
},
"dependencies": {
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
"dev": true,
"optional": true
},
"is-glob": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"dev": true,
"optional": true,
"requires": {
"is-extglob": "^1.0.0"
}
}
}
},
"parse-json": { "parse-json": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
@ -9674,13 +9279,6 @@
"integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=",
"dev": true "dev": true
}, },
"preserve": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz",
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
"dev": true,
"optional": true
},
"prettier": { "prettier": {
"version": "1.19.1", "version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
@ -9838,27 +9436,6 @@
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
"dev": true "dev": true
}, },
"randomatic": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz",
"integrity": "sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==",
"dev": true,
"optional": true,
"requires": {
"is-number": "^4.0.0",
"kind-of": "^6.0.0",
"math-random": "^1.0.1"
},
"dependencies": {
"is-number": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
"integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
"dev": true,
"optional": true
}
}
},
"randombytes": { "randombytes": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@ -10074,16 +9651,6 @@
"private": "^0.1.6" "private": "^0.1.6"
} }
}, },
"regex-cache": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz",
"integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==",
"dev": true,
"optional": true,
"requires": {
"is-equal-shallow": "^0.1.3"
}
},
"regex-not": { "regex-not": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
@ -12204,12 +11771,6 @@
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
"integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ=="
}, },
"user-home": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz",
"integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=",
"dev": true
},
"util": { "util": {
"version": "0.11.1", "version": "0.11.1",
"resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz", "resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz",

View File

@ -39,12 +39,12 @@
"@babel/core": "^7.7.5", "@babel/core": "^7.7.5",
"@babel/plugin-proposal-optional-chaining": "^7.7.5", "@babel/plugin-proposal-optional-chaining": "^7.7.5",
"@babel/preset-env": "^7.7.6", "@babel/preset-env": "^7.7.6",
"@babel/register": "^7.7.4",
"autoprefixer": "^9.7.3", "autoprefixer": "^9.7.3",
"babel-cli": "^6.26.0", "babel-core": "^6.26.3",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-preset-airbnb": "^3.3.2", "babel-preset-airbnb": "^3.3.2",
"babel-register": "^6.26.0",
"css-loader": "^2.1.1", "css-loader": "^2.1.1",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1", "eslint-config-airbnb": "^17.1.1",

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,9 @@ async function createThumbnail(buffer) {
height: config.media.thumbnailSize, height: config.media.thumbnailSize,
withoutEnlargement: true, withoutEnlargement: true,
}) })
.jpeg({
quality: 50,
})
.toBuffer(); .toBuffer();
} }

View File

@ -272,19 +272,29 @@ function curateReleases(releases) {
return Promise.all(releases.map(async release => curateRelease(release))); return Promise.all(releases.map(async release => curateRelease(release)));
} }
async function getChannelSite(release) { async function attachChannelSite(release) {
try { if (!release.site.isFallback || !release.channel) {
const site = await findSiteByUrl(release.channel); throw new Error(`Unable to derive channel site from generic URL: ${release.url}.`);
return site || null;
} catch (error) {
const [site] = await fetchSites({
name: release.channel,
slug: release.channel,
});
return site || null;
} }
const [site] = await fetchSites({
name: release.channel,
slug: release.channel,
});
if (site) {
return {
...release,
site,
};
}
const urlSite = await findSiteByUrl(release.channel);
return {
...release,
site: urlSite,
};
} }
async function curateReleaseEntry(release) { async function curateReleaseEntry(release) {
@ -307,15 +317,6 @@ async function curateReleaseEntry(release) {
deep: typeof release.deep === 'boolean' ? release.deep : false, deep: typeof release.deep === 'boolean' ? release.deep : false,
}; };
if (release.site.isFallback && release.channel) {
const site = await getChannelSite(release);
if (site) {
curatedRelease.site_id = site.id;
return curatedRelease;
}
}
return curatedRelease; return curatedRelease;
} }
@ -477,18 +478,13 @@ async function storeRelease(release) {
async function storeReleases(releases) { async function storeReleases(releases) {
const storedReleases = await Promise.map(releases, async (release) => { const storedReleases = await Promise.map(releases, async (release) => {
if (release.site.isFallback && !release.channel) {
console.error(`Unable to derive channel site from generic URL: ${release.url}.`);
return null;
}
try { try {
const releaseId = await storeRelease(release); const releaseWithChannelSite = await attachChannelSite(release);
const releaseId = await storeRelease(releaseWithChannelSite);
return { return {
id: releaseId, id: releaseId,
...release, ...releaseWithChannelSite,
}; };
} catch (error) { } catch (error) {
console.error(error); console.error(error);

View File

@ -16,7 +16,7 @@ async function scrapeProfile(html, _url, actorName) {
const { document } = new JSDOM(html).window; const { document } = new JSDOM(html).window;
const entries = Array.from(document.querySelectorAll('.infoPiece'), el => el.textContent.replace(/\n|\t/g, '').split(':')); const entries = Array.from(document.querySelectorAll('.infoPiece'), el => el.textContent.replace(/\n|\t/g, '').split(':'));
const bio = entries.reduce((acc, [key, value]) => ({ ...acc, [key.trim()]: value.trim() }), {}); const bio = entries.reduce((acc, [key, value]) => (key ? { ...acc, [key.trim()]: value.trim() } : acc), {});
const profile = { const profile = {
name: actorName, name: actorName,