]> ruin.nu Git - ndwebbie.git/commitdiff
Remove the old stats automatically when parsing
authorMichael Andreen <harv@ruin.nu>
Wed, 2 Jun 2010 20:11:34 +0000 (22:11 +0200)
committerMichael Andreen <harv@ruin.nu>
Wed, 2 Jun 2010 20:11:34 +0000 (22:11 +0200)
scripts/parsealliances.pl
scripts/parsegalaxies.pl
scripts/parseplanets.pl

index 36a80306cab15da43a4479b3bbd0a562d48fdb03..f42414ba53f3d755a04188fb8ebb2c9102c17592 100755 (executable)
@@ -81,6 +81,8 @@ my $findalliance = $dbh->prepare(q{SELECT tick,aid,members,
        members_gain,members_gain_day
 FROM alliance_stats WHERE aid = $1 AND tick < $2 ORDER BY tick DESC LIMIT 1}) or die $dbh->errstr;
 
+$dbh->do(q{DELETE FROM alliance_stats WHERE tick = $1},undef,$tick);
+
 for my $alliance (@alliances) {
 
        $findalliance->execute($alliance->[1],$tick) or die $dbh->errstr;
index 0ba0f0cb160df372c08ed88ad182cc6ecb412e15..f9b6af758c2dbef6bbb56b9617503c6f4c9439a8 100755 (executable)
@@ -77,6 +77,7 @@ my $insert = $dbh->prepare(q{INSERT INTO galaxies(tick, x, y,
        sizerank_gain_day, scorerank_gain_day, valuerank_gain_day, xprank_gain_day,
        planets,planets_gain,planets_gain_day
        ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)});
+$dbh->do(q{DELETE FROM galaxies WHERE tick = $1},undef,$tick);
 my $countplanets = $dbh->prepare(q{SELECT count(*) from planet_stats where x = $1 and y = $2 and tick = $3});
 for my $galaxy (@galaxies) {
 
index a01377f1aa86df741ef15f35218852314310d872..0c62298edc96f501b06907f383c30cbc048dcb1a 100755 (executable)
@@ -85,6 +85,7 @@ while (my @planet = $findplanets->fetchrow){
 }
 my $intel = $dbh->prepare(q{INSERT INTO forum_posts (ftid,uid,message) VALUES(
                (SELECT ftid FROM planets WHERE pid = $2),$1,$3)});
+$dbh->do(q{DELETE FROM planet_stats WHERE tick = $1},undef,$tick);
 for my $planet (@planets) {
        #print "$planet->[1]\n";
        my $oldPlanet = $oldStats{$planet->[1]};