Skip to content

Commit

Permalink
New extended certificate generation window (#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
annagav authored Aug 25, 2023
1 parent 366b675 commit 61e5a44
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"description": "Early executed tasks propagate exceptions",
"required": false
},
"CERTIFICATE_CREATION_DELAY_IN_HOURS": {
"description": "The number of hours to delay automated certificate creation after a course run ends.",
"CERTIFICATE_CREATION_WINDOW_IN_DAYS": {
"description": "The number of days a course run is eligible for certificate creation after it ends.",
"required": false
},
"CLOUDFRONT_DIST": {
Expand Down
8 changes: 4 additions & 4 deletions courses/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,15 +775,15 @@ def get_certificate_grade_eligible_runs(now):
"""
Get the list of course runs that are eligible for Grades update/creation and certificates creation
"""
# Get all the course runs valid course runs for certificates/Grades
# For a valid run it would be live, certificate_available_date would be in future with addition of
# delay settings.CERTIFICATE_CREATION_DELAY_IN_HOURS.
# Get all the course runs eligible for certificates generation
# For a valid run it would be live, certificate_available_date would be in future or within a month of passing
# the certificate_available_date.

course_runs = CourseRun.objects.live().filter(
Q(certificate_available_date__isnull=True)
| Q(
certificate_available_date__gt=now
- timedelta(hours=settings.CERTIFICATE_CREATION_DELAY_IN_HOURS)
- timedelta(days=settings.CERTIFICATE_CREATION_WINDOW_IN_DAYS)
)
)
return course_runs
Expand Down
4 changes: 1 addition & 3 deletions courses/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def test_generate_course_certificates_no_valid_course_run(settings, courses_api_
5,
is_self_paced=False,
certificate_available_date=now_in_utc()
- timedelta(hours=settings.CERTIFICATE_CREATION_DELAY_IN_HOURS + 1),
- timedelta(days=settings.CERTIFICATE_CREATION_WINDOW_IN_DAYS + 1),
)
generate_course_run_certificates()
assert (
Expand Down Expand Up @@ -1184,7 +1184,6 @@ def test_course_certificates_with_course_end_date_self_paced_combination(
end_date,
):
"""Test that correct certificates are created when there are course runs with end_date and self_paced combination"""
settings.CERTIFICATE_CREATION_DELAY_IN_HOURS = 1
course_run = passed_grade_with_enrollment.course_run
course_run.is_self_paced = self_paced
course_run.certificate_available_date = end_date
Expand Down Expand Up @@ -1213,7 +1212,6 @@ def test_generate_course_certificates_with_course_end_date(
mocker, courses_api_logs, passed_grade_with_enrollment, settings
):
"""Test that certificates are generated for passed grades when there are valid course runs for certificates"""
settings.CERTIFICATE_CREATION_DELAY_IN_HOURS = 1
course_run = passed_grade_with_enrollment.course_run
course_run.certificate_available_date = now_in_utc()
course_run.save()
Expand Down
8 changes: 4 additions & 4 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,10 @@
description="'day_of_week' value for 'check-for-program-orphans' scheduled task (default will run once a day).",
)

CERTIFICATE_CREATION_DELAY_IN_HOURS = get_int(
name="CERTIFICATE_CREATION_DELAY_IN_HOURS",
default=24,
description="The number of hours to delay automated certificate creation after a course run ends.",
CERTIFICATE_CREATION_WINDOW_IN_DAYS = get_int(
name="CERTIFICATE_CREATION_WINDOW_IN_DAYS",
default=31,
description="The number of days a course run is eligible for certificate creation after it ends.",
)

RETRY_FAILED_EDX_ENROLLMENT_FREQUENCY = get_int(
Expand Down

0 comments on commit 61e5a44

Please sign in to comment.