summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Users.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-10-10 15:51:57 +0200
committerYorhel <git@yorhel.nl>2009-10-10 15:51:57 +0200
commit5ce2ce4c494feef5940c032549472a52b5282ad1 (patch)
tree89efb88dc1fc0afbb2d4ba3b29a37e154453edeb /lib/VNDB/DB/Users.pm
parent1e125f67ab50a5de477c538b3f7dd27a9ec3c62f (diff)
Display number of unread posts in user menu
Instead of displaying the total number of threads. Posts are marked as read when the thread is opened.
Diffstat (limited to 'lib/VNDB/DB/Users.pm')
-rw-r--r--lib/VNDB/DB/Users.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index b2cd1a31..cb25b9fe 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -54,7 +54,13 @@ sub dbUserGet {
'(SELECT COUNT(DISTINCT vid) FROM tags_vn WHERE uid = u.id) AS tagvncount',
) : (),
$o{what} =~ /mymessages/ ?
- '(SELECT COUNT(*) FROM threads_boards tb JOIN threads t ON t.id = tb.tid WHERE tb.type = \'u\' AND tb.iid = u.id AND t.hidden = FALSE) AS mymessages' : (),
+ q{COALESCE((SELECT SUM(tbi.count) FROM (
+ SELECT t.count-COALESCE(tb.lastread,0)
+ FROM threads_boards tb
+ JOIN threads t ON t.id = tb.tid AND NOT t.hidden
+ WHERE tb.type = 'u' AND tb.iid = u.id) AS tbi (count)
+ ), 0) AS mymessages
+ } : (),
);
my($r, $np) = $s->dbPage(\%o, q|