diff --git a/scripts/register/subscriptions-1.sql b/scripts/register/subscriptions-1.sql index 01812224c..224dd398e 100644 --- a/scripts/register/subscriptions-1.sql +++ b/scripts/register/subscriptions-1.sql @@ -3,5 +3,5 @@ select users.id, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, s where subscriptions.user=users.id and games.id=subscriptions.game and subscriptions.race=races.race - and games.id=1 + and games.id=1 and subscriptions.status='ACTIVE' order by subscriptions.id; diff --git a/scripts/register/subscriptions-2.sql b/scripts/register/subscriptions-2.sql index 0327b4479..1df60311b 100644 --- a/scripts/register/subscriptions-2.sql +++ b/scripts/register/subscriptions-2.sql @@ -3,5 +3,5 @@ select users.id, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, s where subscriptions.user=users.id and games.id=subscriptions.game and subscriptions.race=races.race - and games.id=2 + and games.id=2 and subscriptions.status='ACTIVE' order by subscriptions.id; diff --git a/scripts/register/test.py b/scripts/register/test.py index 592398f51..6c2470860 100755 --- a/scripts/register/test.py +++ b/scripts/register/test.py @@ -1,3 +1,14 @@ -#!/usr/bin/python -import sys -print sys.argv[0], sys.argv[1] +import MySQLdb; +db=MySQLdb.connect(db='vinyambar'); +c=db.cursor() +users=c.execute('select id from users') +while users>0: + users=users-1 + c2=db.cursor() + user=c.fetchone()[0] + a=c2.execute('select id from transactions where user='+str(int(user))) + if a>0: + c2.execute("update users set status='PAYING' where id="+str(int(user))) + else: + c2.execute("update users set status='CONFIRMED' where id="+str(int(user))) + diff --git a/scripts/register/unpaid.sql b/scripts/register/unpaid.sql index 87554d854..ec552e564 100644 --- a/scripts/register/unpaid.sql +++ b/scripts/register/unpaid.sql @@ -1,6 +1,7 @@ -select u.id ID, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand - from users u, transactions t - where u.id=t.user - and u.status!='CONFIRMED' +select distinct u.id ID, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand + from users u, transactions t, subscriptions s + where u.id=t.user and u.id=s.user + and u.status!='CONFIRMED' + and s.status='ACTIVE' GROUP BY u.id HAVING SUM(t.balance)<2.5;