Commit 8659e6da authored by Florent Chehab's avatar Florent Chehab

transaction

parent 20e3a7f2
Pipeline #42717 passed with stages
in 3 minutes and 41 seconds
import logging
import re
from django.db import models
from django.db import models, transaction
from backend_app.fields import JSONField
from backend_app.models.abstract.base import (
......@@ -121,6 +121,7 @@ class UnivMajorMinorsViewSet(BaseModelViewSet):
required_filterset_fields = ("university",)
@transaction.atomic
def update_denormalized_univ_major_minor():
logger.info("Computing the denormalized univ, major and minor")
data = {}
......@@ -139,6 +140,7 @@ def update_denormalized_univ_major_minor():
data[university][student_major].add(student_minor)
UnivMajorMinors.objects.all().delete()
for university, majors_and_minors in data.items():
for major, minors in majors_and_minors.items():
UnivMajorMinors.objects.update_or_create(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment