From 0c5c9bab2c022e251024cc2bd222bd7585ca6837 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 1 Feb 2010 17:45:26 +0100 Subject: Cache the title and userid of the notifications These aren't likely to change anyway, and things will become less easy to display when other types of notifications are added. --- lib/VNDB/DB/Users.pm | 11 ++--------- lib/VNDB/Handler/Users.pm | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm index 63ac2270..bade6ca1 100644 --- a/lib/VNDB/DB/Users.pm +++ b/lib/VNDB/DB/Users.pm @@ -177,21 +177,14 @@ sub dbNotifyGet { ); my @join = ( - $o{what} =~ /titles/ ? ( - q|LEFT JOIN threads t ON n.ltype = 't' AND t.id = n.iid|, - q|LEFT JOIN threads_posts tp ON n.ltype = 't' AND tp.tid = t.id AND n.subid = tp.num|, - q|LEFT JOIN users tu ON tp.uid = tu.id| - ) : () + $o{what} =~ /titles/ ? 'LEFT JOIN users u ON n.c_byuser = u.id' : (), ); my @select = ( qw|n.id n.ntype n.ltype n.iid n.subid|, q|extract('epoch' from n.date) as date|, q|extract('epoch' from n.read) as read|, - $o{what} =~ /titles/ ? ( - q|COALESCE(t.title,'') AS title|, - q|COALESCE(tu.username,'') AS subtitle|, - ) : (), + $o{what} =~ /titles/ ? qw|u.username n.c_title| : (), ); my($r, $np) = $s->dbPage(\%o, q| diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 16111add..7ab21336 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -594,7 +594,7 @@ sub notifies { lit mt '_usern_n_'.( $l->{ltype} eq 't' ? ($l->{subid} == 1 ? 't_new' : 't_reply') : die("unknown notification type")), - sprintf('%s', xml_escape $l->{title}), sprintf('%s', xml_escape $l->{subtitle}); + sprintf('%s', xml_escape $l->{c_title}), sprintf('%s', xml_escape $l->{username}); end; end; }, -- cgit v1.2.3