mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
Merge pull request #5805 from ErisDS/tag-seq
Switch to using sequence for updating tags
This commit is contained in:
commit
c8dd095c36
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user