Skip to content

Commit

Permalink
Merge pull request TryGhost#5805 from ErisDS/tag-seq
Browse files Browse the repository at this point in the history
Switch to using sequence for updating tags
  • Loading branch information
sebgie committed Sep 7, 2015
2 parents c02f7d6 + 449def7 commit c8dd095
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/server/data/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,21 @@ to004 = function to004() {
posts.each(function (post) {
var order = 0;
post.related('tags').each(function (tag) {
tagOps.push(post.tags().updatePivot(
{sort_order: order}, _.extend({}, options, {query: {where: {tag_id: tag.id}}})
));
tagOps.push((function (order) {
var sortOrder = order;
return function () {
return post.tags().updatePivot(
{sort_order: sortOrder}, _.extend({}, options, {query: {where: {tag_id: tag.id}}})
);
};
}(order)));
order += 1;
});
});
}
if (tagOps.length > 0) {
logInfo('Updating order on ' + tagOps.length + ' tags');
return Promise.all(tagOps);
return sequence(tagOps);
}
});
};
Expand Down

0 comments on commit c8dd095

Please sign in to comment.