OneZoom / OZtree

OneZoom Tree of Life Explorer
Other
88 stars 18 forks source link

Fail gracefully if `sponsorship_ends` is NULL #663

Closed hyanwong closed 1 year ago

hyanwong commented 1 year ago

When running grunt exec:background_tasks:localhost:dry-run:log-email:verbose, a bad row in out database has a sponsorship_ends value of NULL, and therefore we get the following error:

Traceback (most recent call last):
  File "/home/web2py/OneZoomComplete_DEV/gluon/shell.py", line 306, in run
    execfile(startfile, _env)
  File "/home/web2py/OneZoomComplete_DEV/gluon/shell.py", line 41, in execfile
    exec(code, global_vars, local_vars)
  File "applications/OZtree/private/background_tasks.py", line 69, in <module>
    for (username, user_reminders) in sponsorship_email_reminders():
  File "/home/web2py/OneZoomComplete_DEV/applications/OZtree/modules/sponsorship.py", line 944, in sponsorship_email_reminders
    elif r.sponsorship_ends <= expiry_critical_date:
TypeError: '<=' not supported between instances of 'NoneType' and 'datetime.datetime'

It would be good to be robust to this somehow. Can we add it as a unit test @lentinj ?

lentinj commented 1 year ago

Easily enough, but what should the response be? Ignore the rows so r.sponsorship_ends == None means never expires?

jrosindell commented 1 year ago

@lentinj yes I think that's right - just skip those cases.

Probably these will never occur in future once the other issues re. setting of r.sponsorship_ends are fixed

lentinj commented 1 year ago

Done with the above, but waiting behind https://github.com/OneZoom/OZtree/pull/666

It's part of #666 now.