Only call member.save() when there's a change

This commit is contained in:
Tanner Collin 2022-01-23 02:33:20 +00:00
parent 0a7bb7e963
commit fddb4e1c1a
2 changed files with 11 additions and 6 deletions

View File

@ -134,6 +134,7 @@ def tally_membership_months(member, fake_date=None):
expire_date = add_months(start_date, total_months) expire_date = add_months(start_date, total_months)
status = calc_member_status(expire_date, fake_date) status = calc_member_status(expire_date, fake_date)
if member.expire_date != expire_date or member.status != status:
member.expire_date = expire_date member.expire_date = expire_date
member.status = status member.status = status
@ -141,6 +142,10 @@ def tally_membership_months(member, fake_date=None):
member.paused_date = expire_date member.paused_date = expire_date
member.save() member.save()
logging.debug('Tallied %s: updated.', member)
else:
logging.debug('Tallied %s: no changes.', member)
return True return True

View File

@ -250,7 +250,7 @@ LOGGING = {
}, },
}, },
'root': { 'root': {
'level': 'INFO', 'level': 'DEBUG' if DEBUG else 'INFO',
'handlers': ['console'], 'handlers': ['console'],
}, },
} }