diff --git a/client/views/posts/modules/post_discuss.html b/client/views/posts/modules/post_discuss.html
index 55a768252..2876bcc78 100644
--- a/client/views/posts/modules/post_discuss.html
+++ b/client/views/posts/modules/post_discuss.html
@@ -1,7 +1,7 @@
\ No newline at end of file
diff --git a/client/views/posts/posts_load_more.js b/client/views/posts/posts_load_more.js
index b276ace68..b31990da6 100644
--- a/client/views/posts/posts_load_more.js
+++ b/client/views/posts/posts_load_more.js
@@ -1,7 +1,7 @@
Template[getTemplate('postsLoadMore')].helpers({
hasMorePosts: function(){
// as long as we ask for N posts and all N posts showed up, then keep showing the "load more" button
- return parseInt(Session.get('postsLimit')) == this.postsCount
+ return parseInt(Session.get('postsLimit')) == this.postCount
},
loadMoreUrl: function () {
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
diff --git a/client/views/users/user_item.html b/client/views/users/user_item.html
index 1f2b7cfe9..ed483236f 100644
--- a/client/views/users/user_item.html
+++ b/client/views/users/user_item.html
@@ -7,8 +7,8 @@
{{getEmail}}
{{createdAtFormatted}} |
- {{postsCount}} |
- {{commentsCount}} |
+ {{postCount}} |
+ {{commentCount}} |
{{getKarma}} |
{{#if invites}}
diff --git a/client/views/users/users.html b/client/views/users/users.html
index af25b25e7..5c9930ca6 100644
--- a/client/views/users/users.html
+++ b/client/views/users/users.html
@@ -15,8 +15,8 @@
{{i18n "Created"}}
{{i18n "Karma"}}
{{i18n "Username"}}
- {{i18n "Posts"}}
-
+ {{i18n "Posts"}}
+
{{i18n "InvitedCount"}}
diff --git a/collections/comments.js b/collections/comments.js
index 274fe1232..4140e1130 100644
--- a/collections/comments.js
+++ b/collections/comments.js
@@ -158,11 +158,11 @@ Meteor.methods({
// increment comment count
Meteor.users.update({_id: user._id}, {
- $inc: {'commentsCount': 1}
+ $inc: {'commentCount': 1}
});
Posts.update(postId, {
- $inc: {commentsCount: 1},
+ $inc: {commentCount: 1},
$set: {lastCommentedAt: now},
$addToSet: {commenters: user._id}
});
@@ -176,13 +176,13 @@ Meteor.methods({
if(canEdit(Meteor.user(), comment)){
// decrement post comment count and remove user ID from post
Posts.update(comment.postId, {
- $inc: {commentsCount: -1},
+ $inc: {commentCount: -1},
$pull: {commenters: comment.userId}
});
// decrement user comment count and remove comment ID from user
Meteor.users.update({_id: comment.userId}, {
- $inc: {'commentsCount': -1}
+ $inc: {'commentCount': -1}
});
// note: should we also decrease user's comment karma ?
diff --git a/collections/posts.js b/collections/posts.js
index 00219d93a..3aee8d811 100644
--- a/collections/posts.js
+++ b/collections/posts.js
@@ -28,11 +28,11 @@ postSchemaObject = {
type: String,
optional: true
},
- viewsCount: {
+ viewCount: {
type: Number,
optional: false
},
- commentsCount: {
+ commentCount: {
type: Number,
optional: false
},
@@ -44,7 +44,7 @@ postSchemaObject = {
type: Date,
optional: true
},
- clicksCount: {
+ clickCount: {
type: Number,
optional: false
},
@@ -225,9 +225,9 @@ Meteor.methods({
author: getDisplayNameById(userId),
upvotes: 0,
downvotes: 0,
- commentsCount: 0,
- clicksCount: 0,
- viewsCount: 0,
+ commentCount: 0,
+ clickCount: 0,
+ viewCount: 0,
baseScore: 0,
score: 0,
inactive: false
@@ -282,7 +282,7 @@ Meteor.methods({
// ------------------------------ Post-Insert ------------------------------ //
// increment posts count
- Meteor.users.update({_id: userId}, {$inc: {postsCount: 1}});
+ Meteor.users.update({_id: userId}, {$inc: {postCount: 1}});
var postAuthor = Meteor.users.findOne(post.userId);
@@ -325,7 +325,7 @@ Meteor.methods({
if(_.where(postViews, view).length == 0){
postViews.push(view);
- Posts.update(postId, { $inc: { viewsCount: 1 }});
+ Posts.update(postId, { $inc: { viewCount: 1 }});
}
},
increasePostClicks: function(postId, sessionId){
@@ -336,7 +336,7 @@ Meteor.methods({
if(_.where(postClicks, click).length == 0){
postClicks.push(click);
- Posts.update(postId, { $inc: { clicksCount: 1 }});
+ Posts.update(postId, { $inc: { clickCount: 1 }});
}
},
deletePostById: function(postId) {
@@ -350,7 +350,7 @@ Meteor.methods({
var post = Posts.findOne({_id: postId});
if(!Meteor.userId() || !canEditById(Meteor.userId(), post)) throw new Meteor.Error(606, 'You need permission to edit or delete a post');
- Meteor.users.update({_id: post.userId}, {$inc: {postsCount: -1}});
+ Meteor.users.update({_id: post.userId}, {$inc: {postCount: -1}});
Posts.remove(postId);
}
});
diff --git a/lib/parameters.js b/lib/parameters.js
index 5bf4de809..9bcbe723f 100644
--- a/lib/parameters.js
+++ b/lib/parameters.js
@@ -58,11 +58,11 @@ getUsersParameters = function(filterBy, sortBy, limit) {
case 'karma':
sort = {karma: -1};
break;
- case 'postsCount':
- sort = {postsCount: -1};
+ case 'postCount':
+ sort = {postCount: -1};
break;
- case 'commentsCount':
- sort = {"commentsCount": -1};
+ case 'commentCount':
+ sort = {"commentCount": -1};
case 'invitedCount':
sort = {invitedCount: -1};
}
diff --git a/lib/publications.js b/lib/publications.js
index de5643520..cc66070fe 100644
--- a/lib/publications.js
+++ b/lib/publications.js
@@ -1,11 +1,11 @@
privacyOptions = { // true means exposed
_id: true,
- commentsCount: true,
+ commentCount: true,
createdAt: true,
email_hash: true,
isInvited: true,
karma: true,
- postsCount: true,
+ postCount: true,
slug: true,
username: true,
'profile.name': true,
diff --git a/lib/router.js b/lib/router.js
index 9c760bf52..185d25594 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -311,7 +311,7 @@ PostsListController = FastRender.RouteController.extend({
}
var parameters = getPostsParameters(this._terms),
- postsCount = Posts.find(parameters.find, parameters.options).count();
+ postCount = Posts.find(parameters.find, parameters.options).count();
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
var posts = Posts.find(parameters.find, parameters.options);
@@ -325,7 +325,7 @@ PostsListController = FastRender.RouteController.extend({
return {
incoming: postsIncoming,
postsList: posts,
- postsCount: postsCount,
+ postCount: postCount,
ready: this.postsListSub.ready
};
},
diff --git a/server/migrations.js b/server/migrations.js
index be20c446d..ed01ff8ff 100644
--- a/server/migrations.js
+++ b/server/migrations.js
@@ -128,13 +128,13 @@ var migrationsList = {
if(typeof user.isAdmin === 'undefined')
properties.isAdmin = false;
- // update postsCount
+ // update postCount
var postsByUser = Posts.find({userId: user._id});
- properties.postsCount = postsByUser.count();
+ properties.postCount = postsByUser.count();
- // update commentsCount
+ // update commentCount
var commentsByUser = Comments.find({userId: user._id});
- properties.commentsCount = commentsByUser.count();
+ properties.commentCount = commentsByUser.count();
Meteor.users.update(user._id, {$set:properties});
@@ -285,12 +285,12 @@ var migrationsList = {
});
return i;
},
- commentsToCommentsCount: function () {
+ commentsToCommentCount: function () {
var i = 0;
- Posts.find({commentsCount: {$exists : false}}).forEach(function (post) {
+ Posts.find({commentCount: {$exists : false}}).forEach(function (post) {
i++;
console.log("Post: "+post._id);
- Posts.update(post._id, { $rename: { 'comments': 'commentsCount'}}, {multi: true, validate: false});
+ Posts.update(post._id, { $rename: { 'comments': 'commentCount'}}, {multi: true, validate: false});
console.log("---------------------");
});
return i;
@@ -355,34 +355,14 @@ var migrationsList = {
});
return i;
},
- commentCountToCommentsCount: function () {
+ clicksToClickCount: function () {
var i = 0;
- Meteor.users.find({"commentsCount": {$exists : false}}).forEach(function (user) {
- i++;
- console.log("User: " + user._id);
- Meteor.users.update(user._id, { $rename: { 'commentCount': 'commentsCount'}}, {multi: true, validate: false});
- console.log("---------------------");
- });
- return i;
- },
- clicksToClicksCount: function () {
- var i = 0;
- Posts.find({"clicksCount": {$exists : false}}).forEach(function (post) {
+ Posts.find({"clickCount": {$exists : false}}).forEach(function (post) {
i++;
console.log("Post: " + post._id);
- Posts.update(post._id, { $rename: { 'clicks': 'clicksCount'}}, {multi: true, validate: false});
+ Posts.update(post._id, { $rename: { 'clicks': 'clickCount'}}, {multi: true, validate: false});
console.log("---------------------");
});
return i;
- },
- postCountToPostsCount: function () {
- var i = 0;
- Meteor.users.find({"postsCount": {$exists : false}}).forEach(function (user) {
- i++;
- console.log("User: " + user._id);
- Meteor.users.update(user._id, { $rename: { 'postCount': 'postsCount'}}, {multi: true, validate: false});
- console.log("---------------------");
- });
- return i;
}
};
\ No newline at end of file
diff --git a/server/users.js b/server/users.js
index 1341f9208..0d9b5b105 100644
--- a/server/users.js
+++ b/server/users.js
@@ -3,8 +3,8 @@ Accounts.onCreateUser(function(options, user){
profile: options.profile || {},
karma: 0,
isInvited: false,
- postsCount: 0,
- commentsCount: 0,
+ postCount: 0,
+ commentCount: 0,
invitedCount: 0,
votes: {
upvotedPosts: [],
|