Skip to content

Commit

Permalink
refactor: speed up finalizing proceedings (#7846)
Browse files Browse the repository at this point in the history
* chore: increase nginx proxy_read_timeout

* refactor: speed up bluesheet_data

The affiliation helper was extremely slow. Using
queryset annotation speeds it up by almost an order
of magnitude.

* chore: delint
  • Loading branch information
jennifer-richards authored Aug 22, 2024
1 parent 9b4671c commit 2230242
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
31 changes: 20 additions & 11 deletions ietf/meeting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

from django.conf import settings
from django.contrib import messages
from django.db.models import Q
from django.db.models import OuterRef, Subquery, TextField, Q, Value
from django.db.models.functions import Coalesce
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.encoding import smart_str
Expand Down Expand Up @@ -149,19 +150,27 @@ def create_proceedings_templates(meeting):


def bluesheet_data(session):
def affiliation(meeting, person):
# from OidcExtraScopeClaims.scope_registration()
email_list = person.email_set.values_list("address")
q = Q(person=person, meeting=meeting) | Q(email__in=email_list, meeting=meeting)
reg = MeetingRegistration.objects.filter(q).exclude(affiliation="").first()
return reg.affiliation if reg else ""

attendance = Attended.objects.filter(session=session).order_by("time")
meeting = session.meeting
attendance = (
Attended.objects.filter(session=session)
.annotate(
affiliation=Coalesce(
Subquery(
MeetingRegistration.objects.filter(
Q(meeting=session.meeting),
Q(person=OuterRef("person")) | Q(email=OuterRef("person__email")),
).values("affiliation")[:1]
),
Value(""),
output_field=TextField(),
)
).distinct()
.order_by("time")
)

return [
{
"name": attended.person.plain_name(),
"affiliation": affiliation(meeting, attended.person),
"affiliation": attended.affiliation,
}
for attended in attendance
]
Expand Down
4 changes: 4 additions & 0 deletions k8s/nginx-auth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ server {
proxy_set_header X-Forwarded-For $${keepempty}proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $${keepempty}remote_addr;
proxy_pass http://localhost:8000;
# Set timeouts longer than Cloudflare proxy limits
proxy_connect_timeout 60; # nginx default (Cf = 15)
proxy_read_timeout 120; # nginx default = 60 (Cf = 100)
proxy_send_timeout 60; # nginx default = 60 (Cf = 30)
}
}
4 changes: 4 additions & 0 deletions k8s/nginx-datatracker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ server {
proxy_set_header X-Forwarded-For $${keepempty}proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $${keepempty}remote_addr;
proxy_pass http://localhost:8000;
# Set timeouts longer than Cloudflare proxy limits
proxy_connect_timeout 60; # nginx default (Cf = 15)
proxy_read_timeout 120; # nginx default = 60 (Cf = 100)
proxy_send_timeout 60; # nginx default = 60 (Cf = 30)
client_max_body_size 0; # disable size check
}
}

0 comments on commit 2230242

Please sign in to comment.