Skip to content

Commit

Permalink
Merge branch 'pcs-front' of https://github.com/pennlabs/penn-courses
Browse files Browse the repository at this point in the history
…into pcs-front
  • Loading branch information
AaDalal committed Aug 14, 2023
2 parents a98f41e + b5408f7 commit f83dbfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 4 additions & 0 deletions backend/review/_optimized_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
qs = ReviewBit.objects.filter(
reviewbit_filters_pcr & Q(review__instructor__id=1),
review__responses__gt=0,
).values("field").annotate(avg=Avg("average", output_field=FloatField())).order_by()
11 changes: 4 additions & 7 deletions backend/review/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,20 @@ class FilledInAdvRegAvg(Subquery):
queryset = queryset.annotate(
**{
**{
(prefix + field): Subquery(
(prefix + group.field): group.avg
for group in Subquery(
ReviewBit.objects.filter(
reviewbit_subfilters,
field=field,
review__responses__gt=0,
)
.values("field")
.order_by()
.annotate(avg=Avg("average"))
.values("avg")[:1],
output_field=FloatField(),
.order_by("field")
)
for field in fields
},
**(
{
(prefix + "final_enrollment"): Subquery(
(prefix + "final_ejjknrollment"): Subquery(
ReviewBit.objects.filter(reviewbit_subfilters, review__responses__gt=0)
.values("review_id", "review__enrollment", "review__section__capacity")
.order_by()
Expand Down

0 comments on commit f83dbfe

Please sign in to comment.