Fixed scene entity tag association.
After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
@ -255,9 +255,6 @@ async function scrapeApiReleases(json, site) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(scene);
|
|
||||||
console.log(release);
|
|
||||||
|
|
||||||
// release.movie = `${site.url}/en/movie/${scene.url_movie_title}/${scene.movie_id}`;
|
// release.movie = `${site.url}/en/movie/${scene.url_movie_title}/${scene.movie_id}`;
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
|
|
16
src/tags.js
|
@ -99,14 +99,20 @@ async function matchReleaseTags(releases) {
|
||||||
|
|
||||||
async function getEntityTags(releases) {
|
async function getEntityTags(releases) {
|
||||||
const entityIds = releases.map((release) => release.entity?.id).filter(Boolean);
|
const entityIds = releases.map((release) => release.entity?.id).filter(Boolean);
|
||||||
const entityTags = await knex('entities_tags').whereIn('entity_id', entityIds);
|
const entityTags = await knex('entities_tags')
|
||||||
|
.select('id', 'name', 'entity_id')
|
||||||
|
.whereIn('entity_id', entityIds)
|
||||||
|
.leftJoin('tags', 'tags.id', 'entities_tags.tag_id');
|
||||||
|
|
||||||
const entityTagIdsByEntityId = entityTags.reduce((acc, entityTag) => {
|
const entityTagIdsByEntityId = entityTags.reduce((acc, entityTag) => {
|
||||||
if (!acc[entityTag.entity_id]) {
|
if (!acc[entityTag.entity_id]) {
|
||||||
acc[entityTag.entity_id] = [];
|
acc[entityTag.entity_id] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
acc[entityTag.entity_id].push(entityTag.tag_id);
|
acc[entityTag.entity_id].push({
|
||||||
|
id: entityTag.id,
|
||||||
|
name: entityTag.name,
|
||||||
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
@ -117,7 +123,7 @@ async function getEntityTags(releases) {
|
||||||
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type) {
|
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type) {
|
||||||
const tagAssociations = releases
|
const tagAssociations = releases
|
||||||
.map((release) => {
|
.map((release) => {
|
||||||
const entityTagIds = entityTagIdsByEntityId[release.entity?.id]?.map((tag) => ({ id: tag.id, origin: tag.name })) || [];
|
const entityTagIds = entityTagIdsByEntityId[release.entity?.id]?.map((tag) => ({ id: tag.id, original: tag.name })) || [];
|
||||||
const releaseTags = release.tags?.filter(Boolean) || [];
|
const releaseTags = release.tags?.filter(Boolean) || [];
|
||||||
|
|
||||||
const releaseTagsWithIds = releaseTags.every((tag) => typeof tag === 'number')
|
const releaseTagsWithIds = releaseTags.every((tag) => typeof tag === 'number')
|
||||||
|
@ -152,9 +158,9 @@ async function associateReleaseTags(releases, type = 'release') {
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagIdsBySlug = await matchReleaseTags(releases);
|
const tagIdsBySlug = await matchReleaseTags(releases);
|
||||||
const EntityTagIdsByEntityId = await getEntityTags(releases);
|
const entityTagIdsByEntityId = await getEntityTags(releases);
|
||||||
|
|
||||||
const tagAssociations = buildReleaseTagAssociations(releases, tagIdsBySlug, EntityTagIdsByEntityId, type);
|
const tagAssociations = buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type);
|
||||||
|
|
||||||
await bulkInsert(`${type}s_tags`, tagAssociations, false);
|
await bulkInsert(`${type}s_tags`, tagAssociations, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,6 @@ async function filterUniqueReleases(releases) {
|
||||||
|
|
||||||
const duplicateReleaseEntries = duplicateReleaseEntryChunks.flat();
|
const duplicateReleaseEntries = duplicateReleaseEntryChunks.flat();
|
||||||
|
|
||||||
console.log(duplicateReleaseEntries);
|
|
||||||
|
|
||||||
const duplicateReleases = duplicateReleaseEntries.map((release) => curateRelease(release));
|
const duplicateReleases = duplicateReleaseEntries.map((release) => curateRelease(release));
|
||||||
const duplicateReleasesByEntityIdAndEntryId = duplicateReleases.reduce(mapReleasesToEntityIdAndEntryId, {});
|
const duplicateReleasesByEntityIdAndEntryId = duplicateReleases.reduce(mapReleasesToEntityIdAndEntryId, {});
|
||||||
|
|
||||||
|
|