More debug output.
This commit is contained in:
parent
2161ff79d9
commit
37498f9ab7
1 changed files with 8 additions and 1 deletions
|
@ -4,7 +4,8 @@ from typing import List, Optional, Any, Type
|
||||||
|
|
||||||
import crypt
|
import crypt
|
||||||
from hmac import compare_digest
|
from hmac import compare_digest
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
from matemat.db.primitives import User, Product, ReceiptPreference, Receipt,\
|
from matemat.db.primitives import User, Product, ReceiptPreference, Receipt,\
|
||||||
Transaction, Consumption, Deposit, Modification
|
Transaction, Consumption, Deposit, Modification
|
||||||
|
@ -577,9 +578,11 @@ class MatematDatabase(object):
|
||||||
user.balance = old_balance + amount
|
user.balance = old_balance + amount
|
||||||
|
|
||||||
def check_receipt_due(self, user: User) -> bool:
|
def check_receipt_due(self, user: User) -> bool:
|
||||||
|
logger = logging.getLogger('matemat.db.facage.check_receipt_due')
|
||||||
if not isinstance(user.receipt_pref, ReceiptPreference):
|
if not isinstance(user.receipt_pref, ReceiptPreference):
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
if user.receipt_pref == ReceiptPreference.NONE or user.email is None:
|
if user.receipt_pref == ReceiptPreference.NONE or user.email is None:
|
||||||
|
logger.debug('Receipt preference None or no e-mail.')
|
||||||
return False
|
return False
|
||||||
with self.db.transaction() as c:
|
with self.db.transaction() as c:
|
||||||
c.execute('''
|
c.execute('''
|
||||||
|
@ -589,8 +592,12 @@ class MatematDatabase(object):
|
||||||
ON r.user_id = u.user_id
|
ON r.user_id = u.user_id
|
||||||
WHERE u.user_id = :user_id
|
WHERE u.user_id = :user_id
|
||||||
''', [user.id])
|
''', [user.id])
|
||||||
|
|
||||||
last_receipt: datetime = datetime.fromtimestamp(c.fetchone()[0])
|
last_receipt: datetime = datetime.fromtimestamp(c.fetchone()[0])
|
||||||
next_receipt_due: datetime = user.receipt_pref.next_receipt_due(last_receipt)
|
next_receipt_due: datetime = user.receipt_pref.next_receipt_due(last_receipt)
|
||||||
|
logger.debug('Last receipt: %s.', last_receipt)
|
||||||
|
logger.debug('Next receipt: %s.', next_receipt_due)
|
||||||
|
logger.debug('Now: %s.', datetime.utcnow())
|
||||||
|
|
||||||
return datetime.utcnow() > next_receipt_due
|
return datetime.utcnow() > next_receipt_due
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue