Skip to content

Commit

Permalink
Merge pull request #1421 from NicoPennec/fix/task-type
Browse files Browse the repository at this point in the history
Improve data loading of Task Type page
  • Loading branch information
NicoPennec authored Apr 22, 2024
2 parents 555616d + 3e075dd commit e9471ff
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions src/components/pages/TaskType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,11 @@ export default {
)
},
scheduleTeam() {
team() {
return sortPeople(
this.currentProduction.team.map(personId =>
this.personMap.get(personId)
)
this.currentProduction.team
.map(personId => this.personMap.get(personId))
.filter(person => !person.is_bot)
)
},
Expand Down Expand Up @@ -753,10 +753,9 @@ export default {
'uploadTaskTypeEstimations'
]),
async initData(force) {
initData(force) {
this.resetTasks()
this.focusSearchField({ preventScroll: true })
await this.loadDaysOff()
if (this.tasks.length < 2) {
this.loading.entities = true
this.errors.entities = false
Expand Down Expand Up @@ -807,19 +806,6 @@ export default {
}
},
async loadDaysOff() {
this.daysOffByPerson = []
for (const person of this.scheduleTeam) {
// load sequentially to avoid too many requests
const daysOff = await this.loadAggregatedPersonDaysOff({
personId: person.id
}).catch(
() => [] // fallback if not allowed to fetch days off
)
this.daysOffByPerson[person.id] = daysOff
}
},
setCurrentScheduleItem() {
const isShots = this.$route.path.includes('shots')
if (this.isTVShow && isShots) {
Expand Down Expand Up @@ -1088,24 +1074,30 @@ export default {
// Schedule
resetScheduleItems() {
async resetScheduleItems() {
const taskAssignationMap = this.buildAssignationMap()
let scheduleItems = this.scheduleTeam
const assignees = Object.keys(taskAssignationMap).filter(
id => id !== 'unassigned' && taskAssignationMap[id].length > 0
)
await this.loadDaysOff(assignees)
const scheduleItems = this.team
.map(person => this.buildPersonElement(person, taskAssignationMap))
.filter(item => item)
.filter(Boolean)
.filter(item => item.children.length > 0)
if (taskAssignationMap.unassigned.length !== 0) {
scheduleItems = scheduleItems.concat([
if (taskAssignationMap.unassigned.length > 0) {
scheduleItems.push(
this.buildPersonElement({ id: 'unassigned' }, taskAssignationMap)
])
)
}
this.schedule.scheduleItems = scheduleItems
},
buildAssignationMap() {
const taskAssignationMap = { unassigned: [] }
this.scheduleTeam.forEach(person => {
this.team.forEach(person => {
if (person) taskAssignationMap[person.id] = []
})
this.tasks.forEach(task => {
Expand All @@ -1123,6 +1115,19 @@ export default {
return taskAssignationMap
},
async loadDaysOff(personIds) {
this.daysOffByPerson = []
for (const personId of personIds) {
// load sequentially to avoid too many requests
const daysOff = await this.loadAggregatedPersonDaysOff({
personId: personId
}).catch(
() => [] // fallback if not allowed to fetch days off
)
this.daysOffByPerson[personId] = daysOff
}
},
buildPersonElement(person, taskAssignationMap) {
if (!person) return null
Expand Down

0 comments on commit e9471ff

Please sign in to comment.