follower and following count on account page

v1.18.x
Baris Soner Usakli 12 years ago
parent 44d07ea543
commit 39cf0476d3

@ -56,6 +56,15 @@
<span class="account-bio-label">posts</span>
<span id='postcount'>{postcount}</span>
<br/>
<span class="account-bio-label">followers</span>
<span>{followerCount}</span>
<br/>
<span class="account-bio-label">following</span>
<span>{followingCount}</span>
<br/>
<hr/>
<span class="account-bio-label">signature</span>
<div class="post-signature">

@ -315,8 +315,16 @@ var user = require('./../user.js'),
data.uid = uid;
data.yourid = callerUID;
data.theirid = uid;
callback(data);
user.getFollowingCount(uid, function(followingCount) {
user.getFollowerCount(uid, function(followerCount) {
data.followingCount = followingCount;
data.followerCount = followerCount;
callback(data);
});
});
}
else
callback({});

@ -34,7 +34,6 @@ var utils = require('./../public/src/utils.js'),
});
}
// a function I feel should be built in user not sure how baris is tackling this so oppa chicken wrapper here
User.getMultipleUserFields = function(uids, fields, callback) {
if(uids.length === 0) {
callback({});
@ -48,7 +47,6 @@ var utils = require('./../public/src/utils.js'),
var data = {},
loaded = 0;
for (var i=0, ii=uuids.length; i<ii; i++) {
(function(user_id) {
User.getUserFields(user_id, fields, function(user_data){
@ -107,8 +105,6 @@ var utils = require('./../public/src/utils.js'),
callback({});
}
User.setUserField = function(uid, field, value) {
RDB.hset('user:'+uid, field, value);
}
@ -117,10 +113,10 @@ var utils = require('./../public/src/utils.js'),
RDB.hincrby('user:'+uid, field, value);
}
User.getUserList = function(callback){
User.getUserList = function(callback) {
var data = [];
RDB.keys('user:*', function(err, userkeys){
RDB.keys('user:*', function(err, userkeys) {
var anonUserIndex = userkeys.indexOf("user:0");
if(anonUserIndex !== -1) {
@ -430,6 +426,24 @@ var utils = require('./../public/src/utils.js'),
});
}
User.getFollowingCount = function(uid, callback) {
RDB.smembers('user:'+uid+':following', function(err, userIds) {
if(err === null)
callback(userIds.length);
else
console.log(err);
});
}
User.getFollowerCount = function(uid, callback) {
RDB.smembers('user:'+uid+':followers', function(err, userIds) {
if(err === null)
callback(userIds.length);
else
console.log(err);
});
}
User.getDataForUsers = function(userIds, callback) {
var returnData = [];

Loading…
Cancel
Save