From 6a03c42459329f8c3f6ddc96cf91e508a6d71c90 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 2 Jun 2010 22:11:34 +0200 Subject: [PATCH] Remove the old stats automatically when parsing --- scripts/parsealliances.pl | 2 ++ scripts/parsegalaxies.pl | 1 + scripts/parseplanets.pl | 1 + 3 files changed, 4 insertions(+) diff --git a/scripts/parsealliances.pl b/scripts/parsealliances.pl index 36a8030..f42414b 100755 --- a/scripts/parsealliances.pl +++ b/scripts/parsealliances.pl @@ -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; diff --git a/scripts/parsegalaxies.pl b/scripts/parsegalaxies.pl index 0ba0f0c..f9b6af7 100755 --- a/scripts/parsegalaxies.pl +++ b/scripts/parsegalaxies.pl @@ -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) { diff --git a/scripts/parseplanets.pl b/scripts/parseplanets.pl index a01377f..0c62298 100755 --- a/scripts/parseplanets.pl +++ b/scripts/parseplanets.pl @@ -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]}; -- 2.39.2