Skip to content

Release 1.143.4#3428

Merged
odlbot merged 4 commits into
releasefrom
release-candidate
Mar 26, 2026
Merged

Release 1.143.4#3428
odlbot merged 4 commits into
releasefrom
release-candidate

Conversation

@odlbot
Copy link
Copy Markdown
Contributor

@odlbot odlbot commented Mar 26, 2026

Chris Chudzicki

James Kachel

annagav

@github-actions
Copy link
Copy Markdown

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
14 changes: 0 error, 0 warning, 14 info
info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'results/items/redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API POST /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '201' status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API PATCH /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API PUT /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v0/orders/receipt/{id}/
		added the optional property 'discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.programpage
		added the required property 'items/items/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/ProgramPageItem]/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/program_certificates/{cert_uuid}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/programs/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/programs/{id}/
		added the required property 'certificate_available' to the response with the '200' status



## Changes for v1.yaml:
14 changes: 0 error, 0 warning, 14 info
info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'results/items/redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API POST /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '201' status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API PATCH /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API PUT /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v0/orders/receipt/{id}/
		added the optional property 'discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.programpage
		added the required property 'items/items/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/ProgramPageItem]/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/program_certificates/{cert_uuid}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/programs/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/programs/{id}/
		added the required property 'certificate_available' to the response with the '200' status



## Changes for v2.yaml:
14 changes: 0 error, 0 warning, 14 info
info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'results/items/redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API POST /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '201' status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API PATCH /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API PUT /api/v0/discounts/{parent_lookup_redeemed_discount}/redemptions/{id}/
		added the optional property 'redeemed_order/discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v0/orders/receipt/{id}/
		added the optional property 'discounts/items/redeemed_discount/allOf[#/components/schemas/Nested]/b2b_sheet_location' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.programpage
		added the required property 'items/items/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/ProgramPageItem]/program_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/program_certificates/{cert_uuid}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'program/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/programs/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/programs/{id}/
		added the required property 'certificate_available' to the response with the '200' status



Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Comment thread b2b/sheets.py
Comment on lines +154 to +158
redemption_date = str(discount.contract_redemptions.last().created_on)

if discount.contract_redemptions.exists():
redeemed_by = discount.contract_redemptions.last().user.email
redeemed_on = str(discount.contract_redemptions.last().created_on)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The _get_discount_cells method causes an N+1 query issue by repeatedly querying the database inside a loop, bypassing the prefetch_related cache with .count() and .last() calls.
Severity: HIGH

Suggested Fix

Refactor the logic to utilize the prefetched data. Instead of calling .count(), use the attach_redemption_count annotation that is already available. Access the prefetched contract_redemptions list in memory to check for existence and retrieve the last item, avoiding new database queries inside the loop.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: b2b/sheets.py#L154-L158

Potential issue: The `_get_discount_cells` method introduces an N+1 query performance
issue. Within a loop that iterates over discount codes, several database queries are
executed for each code using methods like `discount.contract_redemptions.count()`,
`discount.contract_redemptions.last()`, and `discount.contract_redemptions.exists()`.
These calls bypass the existing `prefetch_related` cache, leading to a large number of
unnecessary database queries. For a contract with 100 learners, this could result in
approximately 600 extra queries, causing significant slowdowns in asynchronous tasks and
increased database load.

Did we get this right? 👍 / 👎 to inform future reviews.

@odlbot odlbot merged commit 0b3546a into release Mar 26, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants