Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update django_bulk_update with inbuilt bulk_update #4417

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contentcuration/contentcuration/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging

from django.db.models import Q
from django_bulk_update.helper import bulk_update
from le_utils.constants import content_kinds
from le_utils.constants import format_presets

Expand Down Expand Up @@ -234,7 +233,7 @@ def sync_node_assessment_items(node, original): # noqa C901
node.changed = True

if ai_to_update:
bulk_update(ai_to_update, update_fields=assessment_item_fields)
AssessmentItem.objects.bulk_update(ai_to_update, update_fields=['assessment_item_fields'])
node.changed = True

if files_to_delete:
Expand Down
3 changes: 1 addition & 2 deletions contentcuration/contentcuration/viewsets/assessmentitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re

from django.db import transaction
from django_bulk_update.helper import bulk_update
from le_utils.constants import exercises
from rest_framework import serializers
from rest_framework.permissions import IsAuthenticated
Expand Down Expand Up @@ -193,7 +192,7 @@ def set_files(self, all_objects, all_validated_data=None): # noqa C901
raise ValidationError(
"Attempted to set files to an assessment item that do not have a file on the server"
)
bulk_update(source_files)
File.objects.bulk_update(source_files, ['assessment_item'])

def create(self, validated_data):
with transaction.atomic():
Expand Down
3 changes: 1 addition & 2 deletions contentcuration/contentcuration/viewsets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.db.utils import IntegrityError
from django.http import Http404
from django.http.request import HttpRequest
from django_bulk_update.helper import bulk_update
from django_celery_results.models import TaskResult
from django_filters.constants import EMPTY_VALUES
from django_filters.rest_framework import DjangoFilterBackend
Expand Down Expand Up @@ -323,7 +322,7 @@ def update(self, queryset, all_validated_data):
self.missing_keys = set(all_validated_data_by_id.keys())\
.difference(updated_keys)

bulk_update(updated_objects, update_fields=properties_to_update)
self.child.Meta.model.objects.bulk_update(updated_objects, list(properties_to_update))

return updated_objects

Expand Down
1 change: 0 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ django-redis
django-prometheus
future
sentry-sdk
django-bulk-update
html5lib==1.1
pillow==9.4.0
python-dateutil>=2.8.1
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ django==3.2.23
# django-s3-storage
# djangorestframework
# jsonfield
django-bulk-update==2.2.0
# via -r requirements.in
django-celery-results==2.4.0
# via -r requirements.in
django-cte==1.2.1
Expand Down