Skip to content

Commit aa4025c

Browse files
committed
fix: monthly institution reporter
1 parent ceb9409 commit aa4025c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

osf/management/commands/monthly_reporters_go.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
from django.core.management.base import BaseCommand
55
from django.db import OperationalError as DjangoOperationalError
6-
from elasticsearch6.exceptions import ConnectionError as ElasticConnectionError
6+
from elasticsearch6.exceptions import ConnectionError as Elastic6ConnectionError
7+
from elasticsearch8.exceptions import ConnectionError as Elastic8ConnectionError
78
from psycopg2 import OperationalError as PostgresOperationalError
89

910
from framework.celery_tasks import app as celery_app
1011
import framework.sentry
1112
from osf.metrics.reporters import AllMonthlyReporters
13+
from osf.metrics.reports import MonthlyReport
1214
from osf.metrics.utils import YearMonth
1315

1416

@@ -17,7 +19,8 @@
1719

1820
_CONTINUE_AFTER_ERRORS = (
1921
DjangoOperationalError,
20-
ElasticConnectionError,
22+
Elastic6ConnectionError,
23+
Elastic8ConnectionError,
2124
PostgresOperationalError,
2225
)
2326

@@ -70,11 +73,7 @@ def schedule_monthly_reporter(
7073

7174
@celery_app.task(
7275
name='management.commands.monthly_reporter_do',
73-
autoretry_for=(
74-
DjangoOperationalError,
75-
ElasticConnectionError,
76-
PostgresOperationalError,
77-
),
76+
autoretry_for=_CONTINUE_AFTER_ERRORS,
7877
max_retries=5,
7978
retry_backoff=True,
8079
)
@@ -87,7 +86,8 @@ def monthly_reporter_do(reporter_key: str, yearmonth: str, report_kwargs: dict):
8786

8887
_reports = _reporter.report(**report_kwargs)
8988
for _report in _reports:
90-
_report.report_yearmonth = _reporter.yearmonth
89+
if isinstance(_report, MonthlyReport) and (_report.report_yearmonth is None):
90+
_report.report_yearmonth = _reporter.yearmonth
9191
_report.save()
9292
_followup_task = _reporter.followup_task(_report)
9393
if _followup_task is not None:

0 commit comments

Comments
 (0)