diff --git a/src/components/cells/ValidationHeader.vue b/src/components/cells/ValidationHeader.vue index 64ff9bd4a4..523128ddb5 100644 --- a/src/components/cells/ValidationHeader.vue +++ b/src/components/cells/ValidationHeader.vue @@ -18,6 +18,9 @@ /> @@ -25,6 +28,9 @@ {{ !hiddenColumns[columnId] ? taskTypeMap.get(columnId).name : '' }} diff --git a/src/components/lists/EpisodeStatsList.vue b/src/components/lists/EpisodeStatsList.vue index d3b7970da7..07b7f74e42 100644 --- a/src/components/lists/EpisodeStatsList.vue +++ b/src/components/lists/EpisodeStatsList.vue @@ -20,13 +20,18 @@ :style="getValidationStyle(columnId)" > {{ taskTypeMap.get(columnId).name }} - + {{ taskTypeMap.get(columnId).name }} diff --git a/src/components/lists/ProductionAssetTypeList.vue b/src/components/lists/ProductionAssetTypeList.vue index 1988c65742..a02fdab333 100644 --- a/src/components/lists/ProductionAssetTypeList.vue +++ b/src/components/lists/ProductionAssetTypeList.vue @@ -20,13 +20,18 @@ :style="getValidationStyle(columnId)" > {{ taskTypeMap.get(columnId).name }} - + {{ taskTypeMap.get(columnId).name }} diff --git a/src/components/lists/SequenceStatsList.vue b/src/components/lists/SequenceStatsList.vue index ba0f054156..9322497527 100644 --- a/src/components/lists/SequenceStatsList.vue +++ b/src/components/lists/SequenceStatsList.vue @@ -20,13 +20,18 @@ :style="getValidationStyle(columnId)" > {{ taskTypeMap.get(columnId).name }} - + {{ taskTypeMap.get(columnId).name }} diff --git a/src/components/pages/EpisodeStats.vue b/src/components/pages/EpisodeStats.vue index c9644e4651..6d581eb11c 100644 --- a/src/components/pages/EpisodeStats.vue +++ b/src/components/pages/EpisodeStats.vue @@ -45,6 +45,7 @@ /> @@ -234,7 +235,8 @@ export default { this.taskTypeMap, this.taskStatusMap, this.episodeMap, - this.countMode + this.countMode, + this.currentProduction ) } else { csv.generateStatReports( @@ -243,7 +245,8 @@ export default { this.taskTypeMap, this.taskStatusMap, this.episodeMap, - this.countMode + this.countMode, + this.currentProduction ) } }, diff --git a/src/components/pages/ProductionAssetTypes.vue b/src/components/pages/ProductionAssetTypes.vue index f5c1b76957..cd4f41ae0f 100644 --- a/src/components/pages/ProductionAssetTypes.vue +++ b/src/components/pages/ProductionAssetTypes.vue @@ -153,7 +153,8 @@ export default { this.taskTypeMap, this.taskStatusMap, this.assetTypeMap, - this.countMode + this.countMode, + this.currentProduction ) }, diff --git a/src/components/pages/SequenceStats.vue b/src/components/pages/SequenceStats.vue index 7e3bec8fc6..2ee79502c3 100644 --- a/src/components/pages/SequenceStats.vue +++ b/src/components/pages/SequenceStats.vue @@ -231,7 +231,8 @@ export default { this.taskTypeMap, this.taskStatusMap, this.sequenceMap, - this.countMode + this.countMode, + this.currentProduction ) }, diff --git a/src/lib/csv.js b/src/lib/csv.js index d8e7c81ea3..52c622073a 100644 --- a/src/lib/csv.js +++ b/src/lib/csv.js @@ -1,5 +1,6 @@ import Papa from 'papaparse' +import { getTaskTypePriorityOfProd } from '@/lib/productions' import { getPercentage } from '@/lib/stats' import stringHelpers from '@/lib/string' import { @@ -128,8 +129,7 @@ const csv = { buildCsvFile(name, entries) { const csvContent = csv.turnEntriesToCsvString(entries) - const result = - 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvContent) + const result = `data:text/csv;charset=utf-8,${encodeURIComponent(csvContent)}` const link = document.createElement('a') link.setAttribute('href', result) link.setAttribute('download', `${name}.csv`) @@ -144,22 +144,28 @@ const csv = { taskTypeMap, taskStatusMap, entryMap, - countMode + countMode, + production ) { - const headers = csv.getStatReportsHeaders(mainStats, taskTypeMap) + const headers = csv.getStatReportsHeaders( + mainStats, + taskTypeMap, + production + ) const entries = csv.getStatReportsEntries( mainStats, taskTypeMap, taskStatusMap, entryMap, - countMode + countMode, + production ) const lines = [headers, ...entries] return csv.buildCsvFile(name, lines) }, - getStatReportsHeaders(mainStats, taskTypeMap) { - const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap) + getStatReportsHeaders(mainStats, taskTypeMap, production) { + const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap, production) const initialHeaders = ['Name', '', 'All', ''] return taskTypeIds.reduce((acc, taskTypeId) => { if (taskTypeId !== 'all') { @@ -176,10 +182,11 @@ const csv = { taskTypeMap, taskStatusMap, entryMap, - countMode = 'count' + countMode = 'count', + production ) { let entries = [] - const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap) + const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap, production) const entryIds = getStatsEntryIds(mainStats, entryMap) entryIds.forEach(entryId => { @@ -246,15 +253,21 @@ const csv = { taskTypeMap, taskStatusMap, entryMap, - countMode + countMode, + production ) { - const headers = csv.getStatReportsHeaders(mainStats, taskTypeMap) + const headers = csv.getStatReportsHeaders( + mainStats, + taskTypeMap, + production + ) const entries = csv.getRetakeStatReportsEntries( mainStats, taskTypeMap, taskStatusMap, entryMap, - countMode + countMode, + production ) const lines = [headers, ...entries] return csv.buildCsvFile(name, lines) @@ -265,10 +278,11 @@ const csv = { taskTypeMap, taskStatusMap, entryMap, - countMode = 'count' + countMode = 'count', + production ) { let entries = [] - const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap) + const taskTypeIds = getStatsTaskTypeIds(mainStats, taskTypeMap, production) const entryIds = getStatsEntryIds(mainStats, entryMap) entryIds.forEach(entryId => { @@ -293,13 +307,7 @@ const csv = { ) taskTypeIds.forEach(taskTypeId => { - if (taskTypeId === 'all') { - Object.keys(mainStats[entryId].all).forEach(taskStatusId => { - if (!['max_retake_count', 'evolution'].includes(taskStatusId)) { - lineMap[taskStatusId] = lineMap[taskStatusId].concat(['', '']) - } - }) - } else { + if (taskTypeId !== 'all') { const taskTypeStats = mainStats[entryId][taskTypeId] if (taskTypeStats) { const total = getStatsTotalEntryCount( @@ -319,6 +327,12 @@ const csv = { lineMap ) } + } else { + Object.keys(mainStats[entryId].all).forEach(taskStatusId => { + if (!['max_retake_count', 'evolution'].includes(taskStatusId)) { + lineMap[taskStatusId] = lineMap[taskStatusId].concat(['', '']) + } + }) } }) @@ -413,24 +427,37 @@ const csv = { } } -const getStatsTaskTypeIds = (mainStats, taskTypeMap) => { +const getStatsTaskTypeIds = (mainStats, taskTypeMap, production) => { return Object.keys(mainStats.all) .filter(taskTypeId => taskTypeId !== 'evolution') .sort((a, b) => { if (a === 'all') return 1 if (b === 'all') return -1 - return taskTypeMap.get(a).priority - taskTypeMap.get(b).priority + const taskTypeA = taskTypeMap.get(a) + const taskTypeB = taskTypeMap.get(b) + const taskTypeAPriority = getTaskTypePriorityOfProd(taskTypeA, production) + const taskTypeBPriority = getTaskTypePriorityOfProd(taskTypeB, production) + if (taskTypeAPriority === taskTypeBPriority) { + return taskTypeA.name.localeCompare(taskTypeB.name, undefined, { + numeric: true + }) + } + return taskTypeAPriority - taskTypeBPriority }) } const getStatsEntryIds = (mainStats, entryMap) => { - return Object.keys(mainStats).sort((a, b) => { - if (a === 'all') return -1 - if (b === 'all') return 1 - return entryMap.get(a).name.localeCompare(entryMap.get(b).name, undefined, { - numeric: true + return Object.keys(mainStats) + .filter(entryId => entryId === 'all' || entryMap.get(entryId)) + .sort((a, b) => { + if (a === 'all') return -1 + if (b === 'all') return 1 + return entryMap + .get(a) + .name.localeCompare(entryMap.get(b).name, undefined, { + numeric: true + }) }) - }) } const getStatsTotalCount = (mainStats, taskStatusIds, countMode, entryId) => { @@ -485,7 +512,7 @@ const buildTotalLines = ( name, taskStatusName, count || '0', - percentage + '%' + `${percentage}%` ] }) return lineMap @@ -507,7 +534,7 @@ const addEntryStatusStats = ( const percentage = getPercentage(count, total) lineMap[taskStatusId] = lineMap[taskStatusId].concat([ count || '0', - percentage + '%' + `${percentage}%` ]) }) } diff --git a/src/store/modules/episodes.js b/src/store/modules/episodes.js index 6c0990677e..69493406b7 100644 --- a/src/store/modules/episodes.js +++ b/src/store/modules/episodes.js @@ -455,11 +455,12 @@ const actions = { loadEpisodeStats({ commit, rootGetters }, productionId) { const taskTypeMap = rootGetters.taskTypeMap - commit(SET_EPISODE_STATS, { episodeStats: {}, taskTypeMap }) + const production = rootGetters.currentProduction + commit(SET_EPISODE_STATS, { episodeStats: {}, taskTypeMap, production }) return shotsApi .getEpisodeStats(productionId) .then(episodeStats => { - commit(SET_EPISODE_STATS, { episodeStats, taskTypeMap }) + commit(SET_EPISODE_STATS, { episodeStats, taskTypeMap, production }) return Promise.resolve(episodeStats) }) .catch(console.error) @@ -842,7 +843,8 @@ const mutations = { ) { state.episodeValidationColumns = helpers.sortStatColumns( episodeRetakeStats, - taskTypeMap + taskTypeMap, + production ) state.episodeRetakeStats = episodeRetakeStats },