Skip to content

Commit

Permalink
Updated stalker.pl to update timestamp and added purge script
Browse files Browse the repository at this point in the history
  • Loading branch information
khaytsus committed Oct 25, 2013
1 parent 1e3f8bc commit 5e54e13
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
26 changes: 26 additions & 0 deletions purge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

defaultdays=90
date=`date +%m-%d-%Y_%-H%M`

case $1 in
''|*[!0-9]*)
days=$defaultdays ;;
*)
days=$1 ;;
esac

echo "This script will take a while to run and will likely make your irc"
echo "connections time out. If you want to stop the stalker script in irssi,"
echo -n "do so now and hit enter when ready.."
read $foo

echo ""
echo -n "Starting delete and vacuum for last ${days} days... "

cp nicks.db nicks-${date}.db

sqlite3 nicks.db \
"delete from records where added < date('now','-${days} days'); vacuum;"

echo "Done"
8 changes: 7 additions & 1 deletion stalker.pl
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,13 @@ sub db_add_record
my $result = $sth->fetchrow_hashref;

if ( $result->{nick} eq $nick ) {
#debugPrint( "info", "Record for $nick skipped - already exists." );
# Update the timestamp so we can do purging based on last seen
$sth = $DBH_child->prepare
("update records set added=datetime('now','localtime') where nick='$nick' and host='$host'" );
eval { $sth->execute() };
if ($@) {
debugPrint( "crit", "Failed to update record, database said: $@" );
}
return 1;
}

Expand Down

0 comments on commit 5e54e13

Please sign in to comment.