Fix slow fetch_meeting_attendance command. Fixes #3304. Commit ready for merge
- Legacy-Id: 19429
This commit is contained in:
parent
3386e59a61
commit
c09baf47a5
|
@ -222,7 +222,12 @@ def compute_hirsch_index(citation_counts):
|
||||||
|
|
||||||
def get_meeting_registration_data(meeting):
|
def get_meeting_registration_data(meeting):
|
||||||
""""Retrieve registration attendee data and summary statistics. Returns number
|
""""Retrieve registration attendee data and summary statistics. Returns number
|
||||||
of Registration records created."""
|
of Registration records created.
|
||||||
|
|
||||||
|
MeetingRegistration records are created in realtime as people register for a
|
||||||
|
meeting. This function serves as an audit / reconciliation. Most records are
|
||||||
|
expected to already exist. The function has been optimized with this in mind.
|
||||||
|
"""
|
||||||
num_created = 0
|
num_created = 0
|
||||||
num_processed = 0
|
num_processed = 0
|
||||||
response = requests.get(settings.STATS_REGISTRATION_ATTENDEES_JSON_URL.format(number=meeting.number))
|
response = requests.get(settings.STATS_REGISTRATION_ATTENDEES_JSON_URL.format(number=meeting.number))
|
||||||
|
@ -236,9 +241,8 @@ def get_meeting_registration_data(meeting):
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Could not decode response from registrations API: '%s...'" % (response.content[:64], ))
|
raise RuntimeError("Could not decode response from registrations API: '%s...'" % (response.content[:64], ))
|
||||||
|
|
||||||
|
records = MeetingRegistration.objects.filter(meeting_id=meeting.pk).select_related('person')
|
||||||
# for each user identified in the Registration system
|
meeting_registrations = {r.email:r for r in records}
|
||||||
# Create a DataTracker MeetingRegistration object
|
|
||||||
for registration in decoded:
|
for registration in decoded:
|
||||||
person = None
|
person = None
|
||||||
# capture the stripped registration values for later use
|
# capture the stripped registration values for later use
|
||||||
|
@ -247,19 +251,22 @@ def get_meeting_registration_data(meeting):
|
||||||
affiliation = registration['Company'].strip()
|
affiliation = registration['Company'].strip()
|
||||||
country_code = registration['Country'].strip()
|
country_code = registration['Country'].strip()
|
||||||
address = registration['Email'].strip()
|
address = registration['Email'].strip()
|
||||||
matching = MeetingRegistration.objects.filter(meeting_id=meeting.pk, email=address)
|
if address in meeting_registrations:
|
||||||
if matching.exists():
|
object = meeting_registrations[address]
|
||||||
object = matching.first()
|
|
||||||
created = False
|
created = False
|
||||||
else:
|
else:
|
||||||
object = MeetingRegistration.objects.create(meeting_id=meeting.pk, email=address)
|
object = MeetingRegistration.objects.create(meeting_id=meeting.pk, email=address)
|
||||||
created = True
|
created = True
|
||||||
object.first_name=first_name[:200]
|
|
||||||
object.last_name=last_name[:200]
|
if (object.first_name != first_name[:200] or
|
||||||
object.affiliation=affiliation
|
object.last_name != last_name[:200] or
|
||||||
object.country_code=country_code
|
object.affiliation != affiliation or
|
||||||
object.attended = True
|
object.country_code != country_code):
|
||||||
object.save()
|
object.first_name=first_name[:200]
|
||||||
|
object.last_name=last_name[:200]
|
||||||
|
object.affiliation=affiliation
|
||||||
|
object.country_code=country_code
|
||||||
|
object.save()
|
||||||
|
|
||||||
# Add a Person object to MeetingRegistration object
|
# Add a Person object to MeetingRegistration object
|
||||||
# if valid email is available
|
# if valid email is available
|
||||||
|
|
Loading…
Reference in a new issue