X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=blobdiff_plain;f=scripts%2Fndrank.pl;h=abfd1cec973f356569e148b2d9e35fa19ae31873;hp=cc7c12767e190b8681de3b72f44cdc663703998d;hb=36a13cae169413fc04fbf704d94a2ad797336e6e;hpb=c643b311c8f134a59625192b900aa28b3f12d4f1 diff --git a/scripts/ndrank.pl b/scripts/ndrank.pl index cc7c127..abfd1ce 100755 --- a/scripts/ndrank.pl +++ b/scripts/ndrank.pl @@ -25,20 +25,15 @@ use warnings; use DBI; use DBD::Pg qw(:pg_types); -use LWP::Simple; +use FindBin; +use lib "$FindBin::Bin/../lib"; -our $dbh; -for my $file ("/home/whale/db.pl") -{ - unless (my $return = do $file){ - warn "couldn't parse $file: $@" if $@; - warn "couldn't do $file: $!" unless defined $return; - warn "couldn't run $file" unless $return; - } -} +use ND::DB; + +our $dbh = ND::DB::DB(); $dbh->begin_work; -my $st = $dbh->prepare(q{SELECT uid FROM current_planet_stats p JOIN users u ON p.id = u.planet WHERE alliance_id = 1 ORDER BY score DESC}); +my $st = $dbh->prepare(q{SELECT uid FROM current_planet_stats p JOIN users u USING (pid) WHERE alliance = 'NewDawn' ORDER BY score DESC}); my $update = $dbh->prepare(q{UPDATE users SET rank = ? WHERE uid = ?}); $st->execute; my $rank = 1;