Fixed tags module not dealing with empty releases or tags, added origin tag column to chapter tag table.

This commit is contained in:
DebaucheryLibrarian
2021-10-17 00:28:13 +02:00
parent b1b2ad2111
commit 167df35d37
5 changed files with 19 additions and 9 deletions

View File

@@ -117,7 +117,7 @@ async function getEntityTags(releases) {
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type) {
const tagAssociations = releases
.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, origin: tag.name })) || [];
const releaseTags = release.tags?.filter(Boolean) || [];
const releaseTagsWithIds = releaseTags.every(tag => typeof tag === 'number')
@@ -147,6 +147,10 @@ function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntit
}
async function associateReleaseTags(releases, type = 'release') {
if (releases.length === 0) {
return;
}
const tagIdsBySlug = await matchReleaseTags(releases);
const EntityTagIdsByEntityId = await getEntityTags(releases);