]> ruin.nu Git - ndwebbie.git/blob - scripts/ndrank.pl
LWP::Simple fix for cloudfare
[ndwebbie.git] / scripts / ndrank.pl
1 #!/usr/bin/perl
2 q{
3 /***************************************************************************
4  *   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
20  ***************************************************************************/
21 };
22
23 use strict;
24 use warnings;
25 use DBI;
26 use DBD::Pg qw(:pg_types);
27
28 use FindBin;
29 use lib "$FindBin::Bin/../lib";
30
31 use ND::DB;
32
33 our $dbh = ND::DB::DB();
34
35 $dbh->begin_work;
36 my $st = $dbh->prepare(q{SELECT uid FROM current_planet_stats p JOIN users u USING (pid) WHERE alliance = 'NewDawn' ORDER BY score DESC});
37 my $update = $dbh->prepare(q{UPDATE users SET rank = ? WHERE uid = ?});
38 $st->execute;
39 my $rank = 1;
40 while (my ($uid) = $st->fetchrow){
41         $update->execute($rank,$uid);
42         $rank++;
43 }
44
45 $dbh->commit;
46
47 $dbh->disconnect;