membershipworks: Use bulk_create for Event
All checks were successful
Ruff / ruff (push) Successful in 21s

Work around for issues with GeneratedField. Also faster anyway.
This commit is contained in:
Adam Goldsmith 2024-01-24 18:35:25 -05:00
parent e0b5820bc2
commit ee399e6b64

View File

@ -115,12 +115,23 @@ def scrape_events():
category.clean_fields()
category.save()
for event_data in data["evt"]:
logger.debug(event_data)
event = Event.from_api_dict(event_data)
event.clean_fields()
event.save()
events = Event.objects.bulk_create(
[Event.from_api_dict(event_data) for event_data in data["evt"]],
update_conflicts=True,
update_fields=[
field.attname
for field in Event._meta.get_fields()
if not (
field.auto_created
or field.many_to_many
or not field.concrete
or field.generated
or field.primary_key
)
],
)
for event in events:
try:
event_ext = EventExt.objects.get(event_ptr=event)
except EventExt.DoesNotExist: