0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:18:42 -05:00

Switch to using sequence for updating tags

no issue

- makes upgrading very large numbers of posts & tags more reliable
This commit is contained in:
Hannah Wolfe 2015-09-03 20:02:29 +01:00
parent 7b3d60b727
commit 449def7234

View file

@ -289,16 +289,21 @@ to004 = function to004() {
posts.each(function (post) { posts.each(function (post) {
var order = 0; var order = 0;
post.related('tags').each(function (tag) { post.related('tags').each(function (tag) {
tagOps.push(post.tags().updatePivot( tagOps.push((function (order) {
{sort_order: order}, _.extend({}, options, {query: {where: {tag_id: tag.id}}}) var sortOrder = order;
)); return function () {
return post.tags().updatePivot(
{sort_order: sortOrder}, _.extend({}, options, {query: {where: {tag_id: tag.id}}})
);
};
}(order)));
order += 1; order += 1;
}); });
}); });
} }
if (tagOps.length > 0) { if (tagOps.length > 0) {
logInfo('Updating order on ' + tagOps.length + ' tags'); logInfo('Updating order on ' + tagOps.length + ' tags');
return Promise.all(tagOps); return sequence(tagOps);
} }
}); });
}; };