Created
March 19, 2015 20:40
-
-
Save Sequoia/d8c77ca5ee3d9b2269b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setupJobs() { | |
//group nodes into object w/breakpoint as keys | |
var nodesByBreakpoint = _(vm.claims).chain() | |
.reduce(function (nodes, claim) { | |
return nodes.concat(claim.related_nodes); | |
}, []) | |
.groupBy(function (node) { | |
return node.breakpoint; | |
}) | |
.value(); | |
//remove jobs with no render tree then prep jobs & add to vm | |
_.each(vm.claimsData.jobs_grouped_by_breakpoints, function (jobs) { | |
_(jobs) | |
.reject({render_tree : false}) | |
.each(addJobToVm) | |
.run(); | |
}); | |
function addJobToVm(job) { | |
job.nodes = nodesByBreakpoint[job.breakpoint]; | |
job.newClaim = vm.service.registerNewClaim({ | |
newClaimId: job.breakpoint, | |
jobId: job.screenshooter_job_id | |
}); | |
vm.jobs.push(job); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setupJobs() | |
{ | |
angular.forEach(vm.claimsData.jobs_grouped_by_breakpoints, function (breakpoint) { | |
angular.forEach(breakpoint, function (job) { | |
if (angular.isObject(job.render_tree)) { | |
var foundClaimNodes = []; | |
_.each(vm.claims, function(claim,i) | |
{ | |
_.each(claim.related_nodes, function(node,i2) | |
{ | |
if(node.breakpoint == job.breakpoint) | |
{ | |
foundClaimNodes.push(node); | |
} | |
}); | |
}); | |
job.nodes = foundClaimNodes; | |
job.newClaim = vm.service.registerNewClaim({ | |
newClaimId : job.breakpoint, | |
jobId : job.screenshooter_job_id | |
}); | |
vm.jobs.push(job); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment