summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/site.clj32
-rw-r--r--template/profile.st6
2 files changed, 34 insertions, 4 deletions
diff --git a/src/site.clj b/src/site.clj
index 744c8ee..77ea36b 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -382,7 +382,31 @@ FROM users u
;; Profile
-
+
+
+(defn count-dumps-posted [nick]
+ (:count
+ (first
+ (do-select ["select count(*) from messages m, users u
+ where m.user_id = u.user_id and lower(u.nick) = ?
+ and m.is_image = true" (.toLowerCase nick)]))))
+
+(defn count-dumps-user-faved [nick]
+ (:count
+ (first
+ (do-select ["select count(distinct(m.message_id)) from users u, tags t, messages m
+ where lower(u.nick) = ? and u.user_id = t.user_id
+ and t.tag = 'favorite'
+ and t.message_id = m.message_id and m.is_image = true"
+ (.toLowerCase nick)]))))
+
+(defn count-users-dumps-faved [nick]
+ (:count
+ (first
+ (do-select ["select count(distinct(m.message_id)) from users u, tags t, messages m
+ where t.message_id = m.message_id and t.tag = 'favorite'
+ and m.user_id = u.user_id and lower(u.nick) = ?"
+ (.toLowerCase nick)]))))
(defn profile
([session profile-nick offset] (profile session profile-nick offset "profile"))
([session profile-nick offset template]
@@ -394,6 +418,9 @@ FROM users u
is-home (and nick (= nick profile-nick))
has-avatar (non-empty-string? (user-info :avatar))
offset (maybe-parse-int offset 0)
+ dump-cnt (count-dumps-posted profile-nick)
+ fav-from-cnt (count-dumps-user-faved profile-nick)
+ fav-to-cnt (count-users-dumps-faved profile-nick)
score (lookup-score profile-nick)
dump-offset (* offset *dumps-per-page*)
raw-dumps (logger tags/fetch-dumps-by-nick
@@ -415,6 +442,9 @@ FROM users u
(.setAttribute st "next" (inc offset)))
(.setAttribute st "score" score)
(.setAttribute st "score_ent" (score-to-entity score))
+ (.setAttribute st "dump_cnt" dump-cnt)
+ (.setAttribute st "dumps_user_faved_cnt" fav-from-cnt)
+ (.setAttribute st "users_dumps_faved_cnt" fav-to-cnt)
(if (not= offset 0)
(.setAttribute st "prev" (max (dec offset) 0)))
(.setAttribute st "debug_log_items" (logger))
diff --git a/template/profile.st b/template/profile.st
index c23af55..defe414 100644
--- a/template/profile.st
+++ b/template/profile.st
@@ -38,9 +38,9 @@
</div>
$endif$
-
-
-
+ <div>dumps posted: $dump_cnt$</div>
+ <div>dumps $nick$ faved: $dumps_user_faved_cnt$</div>
+ <div>$nick$'s dumps faved: $users_dumps_faved_cnt$</div>
$if(is_home)$
<div id="avatar-editing" style="display: none">