Skip to content

Conversation

@ceorourke
Copy link
Member

@ceorourke ceorourke commented Sep 30, 2025

Add GroupOpenPeriodActivity results to the group open period serializer response.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 30, 2025
@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #100627      +/-   ##
===========================================
+ Coverage   81.14%    81.19%   +0.05%     
===========================================
  Files        8599      8616      +17     
  Lines      380806    382141    +1335     
  Branches    23911     23911              
===========================================
+ Hits       308993    310271    +1278     
- Misses      71451     71508      +57     
  Partials      362       362              

@ceorourke ceorourke marked this pull request as ready for review September 30, 2025 20:16
@ceorourke ceorourke requested a review from a team as a code owner September 30, 2025 20:16
cursor[bot]

This comment was marked as outdated.

@ceorourke ceorourke requested a review from a team as a code owner October 2, 2025 21:30
@ceorourke ceorourke removed the request for review from a team October 2, 2025 21:30
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

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

lgtm! (also thanks for the initial review malachi!)

Copy link
Contributor

@mifu67 mifu67 left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for doing this!

)
activities = GroupOpenPeriodActivity.objects.filter(
group_open_period__in=item_list
).order_by("id")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also order by date_added, but this works too :)

return GroupOpenPeriodActivityResponse(
id=str(obj.id),
type=OpenPeriodActivityType(obj.type).to_str(),
value=PriorityLevel(obj.value).to_str() if obj.value else None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Serializer Fails to Handle Zero Priority Levels

The GroupOpenPeriodActivitySerializer incorrectly treats obj.value as falsy when its value is 0. Since 0 is a valid PriorityLevel, this causes the serializer to return None instead of the string representation for priority level 0.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

):
gopas[activity.group_open_period].append(serialized_activity)
for item in item_list:
result[item]["activities"] = gopas[item][:100]
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Overfetching and Serialization Issues

The get_attrs method fetches and serializes all GroupOpenPeriodActivity records for each GroupOpenPeriod, even though only the first 100 are used. This can cause significant memory and processing overhead. Additionally, zipping the activities queryset with its serialized output risks an ordering mismatch, potentially leading to incorrect data associations.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

django lazy loads them

@ceorourke ceorourke merged commit 857ba9d into master Oct 3, 2025
65 checks passed
@ceorourke ceorourke deleted the ceorourke/add-gopa-to-gop-endpoint branch October 3, 2025 22:08
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants