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,13 +134,18 @@ 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)
member.expire_date = expire_date if member.expire_date != expire_date or member.status != status:
member.status = status member.expire_date = expire_date
member.status = status
if status == 'Former Member': if status == 'Former Member':
member.paused_date = expire_date member.paused_date = expire_date
member.save()
logging.debug('Tallied %s: updated.', member)
else:
logging.debug('Tallied %s: no changes.', member)
member.save()
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'],
}, },
} }