Skip to content

Commit

Permalink
Import from LTS blogs now properly adds tags to posts. (#7926)
Browse files Browse the repository at this point in the history
closes #7866

- Importer now uses Javascript's Map instead of the normal object to ensure that tags are properly associated with their corresponding posts.
  • Loading branch information
vivekannan authored and kirrg001 committed Jan 31, 2017
1 parent bac8bcf commit 5507ada
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/server/data/import/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ utils = {

preProcessPostTags: function preProcessPostTags(tableData) {
var postTags,
postsWithTags = {};
postsWithTags = new Map();

postTags = tableData.posts_tags;
_.each(postTags, function (postTag) {
if (!postsWithTags.hasOwnProperty(postTag.post_id)) {
postsWithTags[postTag.post_id] = [];
if (!postsWithTags.get(postTag.post_id)) {
postsWithTags.set(postTag.post_id, []);
}
postsWithTags[postTag.post_id].push(postTag.tag_id);
postsWithTags.get(postTag.post_id).push(postTag.tag_id);
});

_.each(postsWithTags, function (tagIds, postId) {
postsWithTags.forEach(function (tagIds, postId) {
var post, tags;
post = _.find(tableData.posts, function (post) {
return post.id === postId;
Expand Down

0 comments on commit 5507ada

Please sign in to comment.