Storing original tags.
This commit is contained in:
18
src/tags.js
18
src/tags.js
@@ -117,22 +117,26 @@ async function getEntityTags(releases) {
|
||||
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type) {
|
||||
const tagAssociations = releases
|
||||
.map((release) => {
|
||||
const entityTagIds = entityTagIdsByEntityId[release.entity?.id] || [];
|
||||
const releaseTags = release.tags || [];
|
||||
const entityTagIds = entityTagIdsByEntityId[release.entity?.id].map(tag => ({ id: tag.id, origin: tag.name })) || [];
|
||||
const releaseTags = release.tags?.filter(Boolean) || [];
|
||||
|
||||
const releaseTagIds = releaseTags.every(tag => typeof tag === 'number')
|
||||
const releaseTagsWithIds = releaseTags.every(tag => typeof tag === 'number')
|
||||
? releaseTags // obsolete scraper returned pre-matched tags
|
||||
: releaseTags.map(tag => tagIdsBySlug[slugify(tag)]);
|
||||
: releaseTags.map(tag => ({
|
||||
id: tagIdsBySlug[slugify(tag)],
|
||||
original: tag,
|
||||
}));
|
||||
|
||||
const tags = [...new Set(
|
||||
// filter duplicates and empties
|
||||
releaseTagIds
|
||||
releaseTagsWithIds
|
||||
.concat(entityTagIds)
|
||||
.filter(Boolean),
|
||||
)]
|
||||
.map(tagId => ({
|
||||
.map(tag => ({
|
||||
[`${type}_id`]: release.id,
|
||||
tag_id: tagId,
|
||||
tag_id: tag.id,
|
||||
original_tag: tag.original,
|
||||
}));
|
||||
|
||||
return tags;
|
||||
|
||||
Reference in New Issue
Block a user