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

CONCD-712 trying to narrow down the error #2300

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Changes from all 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
14 changes: 9 additions & 5 deletions exporter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.postgres.aggregates.general import StringAgg
from django.core.exceptions import SynchronousOnlyOperation
from django.db.models import OuterRef, Subquery
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.decorators import method_decorator
Expand All @@ -28,7 +29,6 @@


def get_latest_transcription_data(asset_qs):
logger.info("Getting latest transcription data for %s assets.", asset_qs.count())
latest_trans_subquery = (
Transcription.objects.filter(asset=OuterRef("pk"))
.order_by("-pk")
Expand All @@ -40,6 +40,7 @@ def get_latest_transcription_data(asset_qs):


def get_tag_values(asset_qs):
logger.info("Getting tag values for %s assets.", asset_qs.count())
assets = asset_qs.annotate(
tag_values=StringAgg("userassettagcollection__tags__value", "; ")
)
Expand Down Expand Up @@ -193,7 +194,6 @@ class ExportCampaignToCSV(TemplateView):

@method_decorator(staff_member_required)
def get(self, request, *args, **kwargs):
logger.info("Exporting %s to csv", self.kwargs["campaign_slug"])
asset_qs = Asset.objects.filter(
item__project__campaign__slug=self.kwargs["campaign_slug"]
)
Expand Down Expand Up @@ -229,9 +229,13 @@ def get(self, request, *args, **kwargs):
},
)

return export_to_csv_response(
"%s.csv" % self.kwargs["campaign_slug"], headers, data
)
logger.info("Exporting %s to csv", self.kwargs["campaign_slug"])
try:
return export_to_csv_response(
"%s.csv" % self.kwargs["campaign_slug"], headers, data
)
except SynchronousOnlyOperation as e:
logger.info("Failed to export csv, error was: %s", e)


class ExportItemToBagIt(TemplateView):
Expand Down