From 30619c5c507d8230d77dbbaf11fa9f8e41ce4a07 Mon Sep 17 00:00:00 2001 From: abram axel booth Date: Mon, 9 Sep 2024 12:25:55 -0400 Subject: [PATCH] bugfixes --- osf/management/commands/monthly_reporters_go.py | 6 ++---- osf/metrics/reporters/_base.py | 2 +- osf/metrics/reporters/institutional_users.py | 6 +++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/osf/management/commands/monthly_reporters_go.py b/osf/management/commands/monthly_reporters_go.py index 8f9854a722b..5734a692d3a 100644 --- a/osf/management/commands/monthly_reporters_go.py +++ b/osf/management/commands/monthly_reporters_go.py @@ -58,10 +58,8 @@ def add_arguments(self, parser): ) def handle(self, *args, **options): - errors = monthly_reporters_go( + monthly_reporters_go( report_year=getattr(options.get('yearmonth'), 'year', None), report_month=getattr(options.get('yearmonth'), 'month', None), ) - for error_key, error_val in errors.items(): - self.stdout.write(self.style.ERROR(f'error running {error_key}: ') + error_val) - self.stdout.write(self.style.SUCCESS('done.')) + self.stdout.write(self.style.SUCCESS('reporter tasks scheduled.')) diff --git a/osf/metrics/reporters/_base.py b/osf/metrics/reporters/_base.py index 24499971ede..9ba6ddc529b 100644 --- a/osf/metrics/reporters/_base.py +++ b/osf/metrics/reporters/_base.py @@ -20,7 +20,7 @@ def report( def run_and_record_for_month(self, report_yearmonth: YearMonth) -> None: reports = self.report(report_yearmonth) for report in reports: - assert report.report_yearmonth == str(report_yearmonth) + assert str(report.report_yearmonth) == str(report_yearmonth) report.save() diff --git a/osf/metrics/reporters/institutional_users.py b/osf/metrics/reporters/institutional_users.py index 0a0598172e0..7c92102851d 100644 --- a/osf/metrics/reporters/institutional_users.py +++ b/osf/metrics/reporters/institutional_users.py @@ -48,7 +48,11 @@ def __post_init__(self): user_id=self.user._id, user_name=self.user.fullname, department_name=(_affiliation.sso_department or None), - month_last_login=YearMonth.from_date(self.user.date_last_login), + month_last_login=( + YearMonth.from_date(self.user.date_last_login) + if self.user.date_last_login is not None + else None + ), account_creation_date=YearMonth.from_date(self.user.created), orcid_id=self.user.get_verified_external_id('ORCID', verified_only=True), public_project_count=self._public_project_queryset().count(),