summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-26 19:46:32 +0100
committerYorhel <git@yorhel.nl>2010-01-26 19:46:32 +0100
commit38174567d7f68a2751426c0fadcda5eca1bd6861 (patch)
tree1d6832acd003ae2e0018ea47408319957dc5ef4c /lib/VNDB/DB
parent4dfb556ecc621b1983d7ad4154db202ec7530e44 (diff)
Keep track of when a session has last been used
If we're going to automatically remove older sessions, it would make more sense to remove unused sessions, rather than old sessions that are still in use. But we first need to keep track of when a session has last been used to do so...
Diffstat (limited to 'lib/VNDB/DB')
-rw-r--r--lib/VNDB/DB/Users.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index 10c90cf6..8805075f 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -6,7 +6,8 @@ use warnings;
use Exporter 'import';
our @EXPORT = qw|
- dbUserGet dbUserEdit dbUserAdd dbUserDel dbSessionAdd dbSessionDel
+ dbUserGet dbUserEdit dbUserAdd dbUserDel
+ dbSessionAdd dbSessionDel dbSessionUpdateLastUsed
dbNotifyGet dbNotifyMarkRead dbNotifyRemove
|;
@@ -66,6 +67,7 @@ sub dbUserGet {
'(SELECT COUNT(DISTINCT tag) FROM tags_vn WHERE uid = u.id) AS tagcount',
'(SELECT COUNT(DISTINCT vid) FROM tags_vn WHERE uid = u.id) AS tagvncount',
) : (),
+ $o{session} ? q|extract('epoch' from s.lastused) as session_lastused| : (),
);
my @join = (
@@ -155,6 +157,12 @@ sub dbSessionDel {
}
+# uid, token
+sub dbSessionUpdateLastUsed {
+ $_[0]->dbExec(q|UPDATE sessions SET lastused = NOW() WHERE uid = ? AND token = decode(?, 'hex')|, $_[1], $_[2]);
+}
+
+
# %options->{ uid id what results page }
# what: titles
sub dbNotifyGet {