Skip to content

Instantly share code, notes, and snippets.

@JFickel
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFickel/3fb1fbcb8d8b9d26cf1c to your computer and use it in GitHub Desktop.
Save JFickel/3fb1fbcb8d8b9d26cf1c to your computer and use it in GitHub Desktop.
for (matchIndex = 0; matchIndex < matchCount; matchIndex++) {
isMatchIndexEven = matchIndex % 2 ? undefined : true;
nextMatchIndex = Math.floor(matchIndex/2);
nextRoundIndex = this.roundCount() - reverseIndex;
builtRounds.findBy('index', nextRoundIndex).get('matches').then(function(matches) {
return matches.findBy('index', nextMatchIndex);
}).then(function(nextMatch) {
nextMatch.get('matchups').then(function(matchups) {
nextMatchup = matchups.findBy('top', isMatchIndexEven);
match = thisStore.createRecord('match', { index: matchIndex, nextMatchupId: nextMatchup.get('id'), round: round });
match.save();
return match
}).then(function(match) {
topMatchup = thisStore.createRecord('matchup', { top: true, match: match });
bottomMatchup = thisStore.createRecord('matchup', { match: match });
topMatchup.save();
bottomMatchup.save();
match.get('matchups').then(function(matchups) {
matchups.pushObject(topMatchup);
matchups.pushObject(bottomMatchup);
match.save();
});
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment