Make importer more resilient

This commit is contained in:
Christian Cueni 2023-08-21 14:55:37 +02:00
parent 615d464045
commit 6ba3be2710
4 changed files with 17 additions and 12 deletions

Binary file not shown.

View File

@ -1,26 +1,24 @@
import structlog
from django.core.exceptions import PermissionDenied
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from rest_framework.decorators import api_view
from vbv_lernwelt.course.permissions import has_course_access_by_page_request
from vbv_lernwelt.edoniq_test.edoniq_sso import create_token
from vbv_lernwelt.learnpath.models import LearningContentEdoniqTest
logger = structlog.get_logger(__name__)
import csv
from datetime import date
from itertools import chain
from typing import List
import structlog
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import PermissionDenied
from django.db.models import CharField, Q, Value
from django.http import HttpResponse
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404
from rest_framework.decorators import api_view
from vbv_lernwelt.core.models import User
from vbv_lernwelt.course.consts import COURSE_UK, COURSE_UK_FR, COURSE_UK_IT
from vbv_lernwelt.course.models import CourseSessionUser
from vbv_lernwelt.course.permissions import has_course_access_by_page_request
from vbv_lernwelt.edoniq_test.edoniq_sso import create_token
from vbv_lernwelt.learnpath.models import LearningContentEdoniqTest
logger = structlog.get_logger(__name__)
UK_COURSE_IDS = [COURSE_UK, COURSE_UK_FR, COURSE_UK_IT]
DEFAULT_EXCLUDED_DOMAINS = ["eiger-versicherung.ch", "assurance.ch", "example.com"]

View File

@ -368,6 +368,12 @@ def create_or_update_course_session_attendance(
start: datetime,
end: datetime,
):
logger.debug(
"create_or_update_course_session_attendance",
slug=f"{course_slug}-lp-circle-{circle_slug}",
start=start,
end=end,
)
csa, _created = CourseSessionAttendanceCourse.objects.get_or_create(
course_session=cs, learning_content=attendance_course_lc
)

View File

@ -80,6 +80,7 @@ def try_parse_datetime(
"%Y-%m-%d %H:%M:%S",
"%Y-%m-%d %H:%M",
"%d.%m.%Y, %H:%M",
"%d.%m.%Y, %H.%M",
],
dayfirst=True,
)