kippnorcal / google_classroom

Google Classroom Data Pipeline
GNU General Public License v3.0
22 stars 9 forks source link

Usage Data fail on first run #68

Closed denglender closed 4 years ago

denglender commented 4 years ago

@dchess - Was thinking more about the error we looked at today, and (admittedly not having fully immersed myself in the code), I don't think it was due to not having quotes around the date in the .env file.

I think it will always fail if there is no data in the student usage table and that it only worked today because my workaround fed data into the student usage data prior uncommenting the original code.

        usage = StudentUsage(admin_reports_service, sql, config, org_unit_id)
        last_date = usage.get_last_date()
        start_date = last_date + timedelta(days=1) or datetime.strptime(config.SCHOOL_YEAR_START, "%Y-%m-%d")

My quick read of StudentUsage.get_last_date() is that it's going to return None if there's no data previously loaded in the table, at which point the next line will throw an error because you can't add to None.

I had enough energy to type up this issue, but not enough to clear my database and try from scratch again to double check, so hopefully this is useful, and apologies if it's a false alarm.

zkagin commented 4 years ago

@denglender I just confirmed the error I assume you're receiving (TypeError: unsupported operand type(s) for +: 'NoneType' and 'datetime.timedelta'), and will have a fix out shortly.

denglender commented 4 years ago

Correct!


From: zkagin notifications@github.com Sent: Thursday, April 30, 2020 12:00:21 AM To: kipp-bayarea/google_classroom google_classroom@noreply.github.com Cc: Daniel Englender denglender@dcprep.org; Mention mention@noreply.github.com Subject: Re: [kipp-bayarea/google_classroom] Usage Data fail on first run (#68)

CAUTION: The email below was sent from outside DC Prep. Do not click on links or open attachments unless you recognize the sender and know that the content is safe. If you believe that this email is suspicious, please forward to 'helpdesk@dcprep.org' and DO NOT RESPOND to the sender.

@denglenderhttps://github.com/denglender I just confirmed the error I assume you're receiving (TypeError: unsupported operand type(s) for +: 'NoneType' and 'datetime.timedelta'), and will have a fix out shortly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kipp-bayarea/google_classroom/issues/68#issuecomment-621598579, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEJDUUBCAQFMQPNCBXJGDMLRPDZVLANCNFSM4MVEJLZA.

zkagin commented 4 years ago

PR submitted, @dchess to review / merge when ready.

dchess commented 4 years ago

@denglender I've merged this fix. You can pull the latest changes to your local now.