summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/lib/views/index.js16
-rw-r--r--views/profile.ejs2
2 files changed, 14 insertions, 4 deletions
diff --git a/server/lib/views/index.js b/server/lib/views/index.js
index 6ceef7e..8c3e63d 100644
--- a/server/lib/views/index.js
+++ b/server/lib/views/index.js
@@ -171,15 +171,20 @@ var views = module.exports = {
if ( ! isOwnProfile ) {
criteria.privacy = false
}
- views_middleware.fetchProjects(criteria, null, null, done)
+ views_middleware.fetchProjects(criteria, null, null, function(err, projects){
+ views_middleware.fetchUserProjectCount(criteria, function(projectCount){
+ done(err, projects, projectCount)
+ })
+ })
}
- function done(err, projects){
+ function done(err, projects, projectCount){
if (! user) { return res.redirect('/') }
res.render('profile', {
isOwnProfile: isOwnProfile,
profile: user,
projects: projects || [],
+ projectCount: projectCount,
ogTitle: "VValls: Profile of " + user.displayName,
ogUrl: "http://vvalls.com/profile/" + user.username + "/",
ogImage: user.photo,
@@ -240,5 +245,10 @@ var views_middleware = {
})
next(err, projects)
})
- }
+ },
+ fetchUserProjectCount: function(criteria, next){
+ Project.count(criteria, function(err, count){
+ next(count || 0)
+ })
+ },
}
diff --git a/views/profile.ejs b/views/profile.ejs
index 5043df6..a62652c 100644
--- a/views/profile.ejs
+++ b/views/profile.ejs
@@ -46,7 +46,7 @@
[[ if (projects.length) { ]]
- <h1>[[- profile.username ]] has [[- projects.length ]] project[[- projects.length != 1 ? "s" : "" ]]</h1>
+ <h1>[[- profile.username ]] has [[- projectCount ]] project[[- projectCount != 1 ? "s" : "" ]]</h1>
[[ include projects/list-projects ]]
[[ } else { ]]