mirror of
https://github.com/status-im/burnchart.git
synced 2025-02-09 09:03:52 +00:00
fetch missing milestones on project page
This commit is contained in:
parent
956e8cc846
commit
3101287e87
@ -28,27 +28,34 @@ module.exports = Ractive.extend
|
||||
# Should not happen...
|
||||
throw 500 unless project
|
||||
|
||||
# Does it have milestones already?
|
||||
return @set('ready', yes) if project.milestones
|
||||
|
||||
# We are loading the milestones then.
|
||||
# We don't know if we have all milestones, so fetch them.
|
||||
done = do system.async
|
||||
|
||||
findMilestone = (number) ->
|
||||
_.find project.milestones or [], { number }
|
||||
|
||||
fetchMilestones = (cb) ->
|
||||
milestones.fetchAll project, cb
|
||||
|
||||
fetchIssues = (allMilestones, cb) ->
|
||||
async.map allMilestones, (milestone, cb) ->
|
||||
async.each allMilestones, (milestone, cb) ->
|
||||
# Maybe we have this milestone already?
|
||||
return cb null if findMilestone milestone.number
|
||||
# Need to fetch the issues then.
|
||||
issues.fetchAll { owner, name, 'milestone': milestone.number }, (err, obj) ->
|
||||
cb err, _.extend milestone, { 'issues': obj }
|
||||
return cb err if err
|
||||
# Save the milestone with issues.
|
||||
project.push 'milestones', _.extend milestone, { 'issues': obj }
|
||||
cb null
|
||||
, cb
|
||||
|
||||
# Run it.
|
||||
async.waterfall [
|
||||
# First get all the milestones.
|
||||
fetchMilestones,
|
||||
# Then all the issues per milestone.
|
||||
fetchIssues
|
||||
], (err, data) =>
|
||||
], (err) =>
|
||||
do done
|
||||
return mediator.fire '!app/notify', {
|
||||
'text': do err.toString
|
||||
@ -57,7 +64,5 @@ module.exports = Ractive.extend
|
||||
'ttl': null
|
||||
} if err
|
||||
|
||||
# Save the milestones.
|
||||
@set
|
||||
'project.milestones': data
|
||||
'ready': yes
|
||||
# Say we are ready.
|
||||
@set 'ready', yes
|
||||
|
Loading…
x
Reference in New Issue
Block a user