mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
do not try updating categories count if post has no categories
This commit is contained in:
parent
aea9c327f9
commit
adc7fd0965
3 changed files with 10 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
## v0.23.2
|
## v0.24 “SubScope2”
|
||||||
|
|
||||||
* [BREAKING] Modules data context must now be passed on explicitely using the `moduleData` attribute.
|
* [BREAKING] Modules data context must now be passed on explicitely using the `moduleData` attribute.
|
||||||
* [BREAKING] Updated `category_title` template.
|
* [BREAKING] Updated `category_title` template.
|
||||||
|
@ -22,7 +22,8 @@
|
||||||
* Now filtering out categories with no posts from the categories menu.
|
* Now filtering out categories with no posts from the categories menu.
|
||||||
* Added `postDeleteAsync` callback hook.
|
* Added `postDeleteAsync` callback hook.
|
||||||
* Now publishing all public user data all the time to work around nested fields subscriptions bug.
|
* Now publishing all public user data all the time to work around nested fields subscriptions bug.
|
||||||
|
* Categories with same name now get different, unique slugs.
|
||||||
|
* Now getting link source name and URL from Embedly if available.
|
||||||
|
|
||||||
## v0.23 “SubScope”
|
## v0.23 “SubScope”
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ getEmbedlyData = function (url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var embedlyData = _.pick(result.data, 'title', 'media', 'description', 'thumbnailUrl', 'sourceName', 'sourceUrl');
|
var embedlyData = _.pick(result.data, 'title', 'media', 'description', 'thumbnailUrl', 'sourceName', 'sourceUrl');
|
||||||
console.log(embedlyData);
|
|
||||||
|
|
||||||
return embedlyData;
|
return embedlyData;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ Telescope.callbacks.add("postClass", addCategoryClass);
|
||||||
|
|
||||||
// when a category is added to a post, increment counter
|
// when a category is added to a post, increment counter
|
||||||
function updateCategoryCountOnSubmit (post) {
|
function updateCategoryCountOnSubmit (post) {
|
||||||
Categories.update({_id: {$in: post.categories}}, {$inc: {"postsCount": 1}}, {multi: true});
|
if (!_.isEmpty(post.categories))
|
||||||
|
Categories.update({_id: {$in: post.categories}}, {$inc: {"postsCount": 1}}, {multi: true});
|
||||||
}
|
}
|
||||||
Telescope.callbacks.add("postSubmitAsync", updateCategoryCountOnSubmit);
|
Telescope.callbacks.add("postSubmitAsync", updateCategoryCountOnSubmit);
|
||||||
|
|
||||||
|
@ -30,8 +31,11 @@ function updateCategoryCountOnEdit (newPost, oldPost) {
|
||||||
var categoriesAdded = _.difference(newPost.categories, oldPost.categories);
|
var categoriesAdded = _.difference(newPost.categories, oldPost.categories);
|
||||||
var categoriesRemoved = _.difference(oldPost.categories, newPost.categories);
|
var categoriesRemoved = _.difference(oldPost.categories, newPost.categories);
|
||||||
|
|
||||||
Categories.update({_id: {$in: categoriesAdded}}, {$inc: {"postsCount": 1}}, {multi: true});
|
if (!_.isEmpty(categoriesAdded))
|
||||||
Categories.update({_id: {$in: categoriesRemoved}}, {$inc: {"postsCount": -1}}, {multi: true});
|
Categories.update({_id: {$in: categoriesAdded}}, {$inc: {"postsCount": 1}}, {multi: true});
|
||||||
|
|
||||||
|
if (!_.isEmpty(categoriesRemoved))
|
||||||
|
Categories.update({_id: {$in: categoriesRemoved}}, {$inc: {"postsCount": -1}}, {multi: true});
|
||||||
}
|
}
|
||||||
Telescope.callbacks.add("postEditAsync", updateCategoryCountOnEdit);
|
Telescope.callbacks.add("postEditAsync", updateCategoryCountOnEdit);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue