From 22e01a2d8e4617bf67485428c196d61e86f5c69c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Mar 2002 10:51:34 +0000 Subject: [PATCH] updates, NMRs, etc. --- scripts/register/zat.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/register/zat.py b/scripts/register/zat.py index d47a41c69..4fa2d3757 100755 --- a/scripts/register/zat.py +++ b/scripts/register/zat.py @@ -1,14 +1,28 @@ #!/usr/bin/env python import MySQLdb import sys +import os dbname=sys.argv[1] game=int(sys.argv[2]) date=sys.argv[3] price=1.25 db=MySQLdb.connect(db=dbname) +patchdir='/home/eressea/vinyambar-rsync/vin'+str(game)+'/data' + cursor=db.cursor() +k = cursor.execute('select name, patch from games where id='+str(game)) +if k==0: + print "Unbekanntes Spiel" + +name, patch = cursor.fetchone() +print "Auswertung für " + name + " Patch Level " + str(int(patch)) +while os.access(patchdir+'/patch-'+str(int(patch+1))+'.sql', os.F_OK)==0: + patch=patch+1 + os.system('mysql --table ' + dbname + '-e ' + patchdir+'/patch-'+str(int(patch+1))+'.sql') + cursor.execute('update games set patch='+str(int(patch))+' where game='+str(game)) + k = cursor.execute("UPDATE subscriptions SET user=NULL where status='TRANSFERED' and updated<'"+date+"'" print "Removing "+str(int(k))+" transfered subscriptions." @@ -18,6 +32,12 @@ print "Removing "+str(int(k))+" cancelled subscriptions." k = cursor.execute("UPDATE subscriptions SET user=NULL where status='DEAD' and updated<'"+date+"'" print "Removing "+str(int(k))+" dead subscriptions." +k = cursor.execute("SELECT max(lastturn) from subscriptions"); +lastturn = int(cursor.fetchone()[0]) +k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where lastturn+3<="+str(lastturn) +k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where NMR>2" +print "Cancelling "+str(int(k))+" subscriptions with 3+ NMRs." + k = cursor.execute("SELECT users.id FROM users, subscriptions WHERE users.id=subscriptions.user and subscriptions.status='ACTIVE' and subscriptions.game="+str(game)) while k!=0: k=k-1