mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merged
This commit is contained in:
parent
2fd22e9d41
commit
6e863598d1
13 changed files with 42 additions and 62 deletions
|
@ -9,7 +9,7 @@
|
|||
<a href="#" class="approve-link goto-edit">Approve</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
| {{i18n "score"}}: {{shortScore}}, {{i18n "clicks"}}: {{clicksCount}}, {{i18n "views"}}: {{viewsCount}}
|
||||
| {{i18n "score"}}: {{shortScore}}, {{i18n "clicks"}}: {{clickCount}}, {{i18n "views"}}: {{viewCount}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template name="postCommentsLink">
|
||||
<div class="post-meta-item">
|
||||
<a class="comments-link" href="/posts/{{_id}}">
|
||||
<span class="count">{{commentsCount}}</span>
|
||||
<span class="count">{{commentCount}}</span>
|
||||
<span class="action">{{i18n 'Comments'}}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template name="postDiscuss">
|
||||
<a class="discuss-link go-to-comments" href="/posts/{{_id}}">
|
||||
<i class="icon-comment"></i>
|
||||
<span class="count">{{commentsCount}}</span>
|
||||
<span class="count">{{commentCount}}</span>
|
||||
<span class="action">{{i18n 'Discuss'}}</span>
|
||||
</a>
|
||||
</template>
|
|
@ -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));
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<a href="mailto:{{getEmail}}">{{getEmail}}</a>
|
||||
</td>
|
||||
<td>{{createdAtFormatted}}</td>
|
||||
<td>{{postsCount}}</td>
|
||||
<td>{{commentsCount}}</td>
|
||||
<td>{{postCount}}</td>
|
||||
<td>{{commentCount}}</td>
|
||||
<td>{{getKarma}}</td>
|
||||
<td>
|
||||
{{#if invites}}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
<a class="{{activeClass 'createdAt'}}" href="{{sortBy 'createdAt'}}">{{i18n "Created"}}</a>
|
||||
<a class="{{activeClass 'karma'}}" href="{{sortBy 'karma'}}">{{i18n "Karma"}}</a>
|
||||
<a class="{{activeClass 'username'}}" href="{{sortBy 'username'}}">{{i18n "Username"}}</a>
|
||||
<a class="{{activeClass 'postsCount'}}" href="{{sortBy 'postsCount'}}">{{i18n "Posts"}}</a>
|
||||
<a class="{{activeClass 'commentsCount'}}" href="{{sortBy 'commentsCount'}}">{{i18n "Comments"}}</a>
|
||||
<a class="{{activeClass 'postCount'}}" href="{{sortBy 'postCount'}}">{{i18n "Posts"}}</a>
|
||||
<a class="{{activeClass 'commentCount'}}" href="{{sortBy 'commentCount'}}">{{i18n "Comments"}}</a>
|
||||
<a class="{{activeClass 'invitedCount'}}" href="{{sortBy 'invitedCount'}}">{{i18n "InvitedCount"}}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -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 ?
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
};
|
||||
},
|
||||
|
|
|
@ -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,32 +355,12 @@ 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});
|
||||
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});
|
||||
Posts.update(post._id, { $rename: { 'clicks': 'clickCount'}}, {multi: true, validate: false});
|
||||
console.log("---------------------");
|
||||
});
|
||||
return i;
|
||||
|
|
|
@ -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: [],
|
||||
|
|
Loading…
Add table
Reference in a new issue