From: Michael Andreen Date: Sat, 20 Sep 2008 09:22:56 +0000 (+0200) Subject: updated laston X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=f25cb4f16b281bf4b5fff8f711155c7297c7eba4;p=NDIRC.git updated laston --- diff --git a/Usermgm.pm b/Usermgm.pm index 76fd5ad..a37dc70 100644 --- a/Usermgm.pm +++ b/Usermgm.pm @@ -140,26 +140,30 @@ sub laston { $flag = $1; $min = $2; $min = 0 unless defined $min; - $f = $ND::DBH->prepare(qq{SELECT username,last,lastforum - FROM (SELECT uid,username, date_part('day',now() - laston)::int AS last - ,date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid))::int AS lastforum - ,laston FROM users u) u + $f = $ND::DBH->prepare(q{SELECT username + ,date_part('day',now() - laston)::int AS last + ,COALESCE(date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid))::text,'?') + AS lastforum + ,COALESCE(date_part('day',now() - (SELECT max(timestamp) FROM raid_claims WHERE uid = u.uid))::text,'?') AS lastclaim + FROM users u NATURAL JOIN groupmembers NATURAL JOIN groups - WHERE flag = ? AND (last >= ? OR last IS NULL) + WHERE flag = $1 AND COALESCE(date_part('day',now() - laston) >= $2,TRUE) ORDER BY laston }); $f->execute($flag,$min); }elsif(defined $msg && $msg =~ /^(\S+)$/){ - $f = $ND::DBH->prepare(qq{SELECT username,last,lastforum - FROM (SELECT uid,username, date_part('day',now() - laston)::int AS last - ,date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid))::int AS lastforum - , laston FROM users u) u - WHERE username ILIKE ? ORDER BY lower(username) + $f = $ND::DBH->prepare(q{SELECT username + ,date_part('day',now() - laston)::int AS last + ,COALESCE(date_part('day',now() - (SELECT max(time) FROM forum_thread_visits WHERE uid = u.uid))::text,'?') + AS lastforum + ,COALESCE(date_part('day',now() - (SELECT max(timestamp) FROM raid_claims WHERE uid = u.uid))::text,'?') AS lastclaim + FROM users u + WHERE username ILIKE $1 ORDER BY lower(username) }); $f->execute($1); }else{ - $ND::server->command("notice $ND::nick syntax: .$command | lists users and the number of days since they were last seen (irc|forum). If days is specified it will only list users with at least that amount of idle time."); + $ND::server->command("notice $ND::nick syntax: .$command | lists users and the number of days since they were last seen (irc|forum|claim). If days is specified it will only list users with at least that amount of idle time."); return; } @@ -167,8 +171,7 @@ sub laston { my $i = 0; while (my $user = $f->fetchrow_hashref){ $user->{last} = '?' unless defined $user->{last}; - $user->{lastforum} = '?' unless defined $user->{lastforum}; - $text .= "$user->{username}($user->{last}|$user->{lastforum}) "; + $text .= "$user->{username}($user->{last}|$user->{lastforum}|$user->{lastclaim}) "; $i++; } $ND::server->command("msg $ND::target $ND::B$i$ND::B Users(days)".(defined $flag ? " with flag $ND::B$flag$ND::B" : "").": $text");