Skip to content

Commit

Permalink
Merge pull request #48 from filips123/fix-updaters-and-empty-timetable
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 authored Aug 31, 2022
2 parents c13e759 + b378454 commit a442e9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion API/gimvicurnik/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Index,
Integer,
SmallInteger,
String,
Text,
Time,
func,
Expand Down Expand Up @@ -66,7 +67,7 @@ class Document(Base):
title = Column(Text, nullable=True)
hash = Column(Text, nullable=True)
parsed = Column(Boolean, nullable=True)
content = Column(Text, nullable=True)
content = Column(String(70000), nullable=True)


class Entity:
Expand Down Expand Up @@ -167,6 +168,9 @@ def get_empty(cls) -> Iterator[Dict[str, Any]]:
days = (1, 5)
times = Session.query(func.min(Lesson.time), func.max(Lesson.time))[0]

if times[0] is None or times[1] is None:
return []

classrooms = list(Session.query(Classroom).order_by(Classroom.name))
lessons = list(Session.query(Lesson).join(Classroom))

Expand Down
6 changes: 5 additions & 1 deletion API/gimvicurnik/updaters/eclassroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

if typing.TYPE_CHECKING:
from typing import Any, Dict, Iterator, List, Optional
from mammoth.documents import Image # type: ignore
from sqlalchemy.orm import Session
from sentry_sdk.tracing import Span
from ..config import ConfigSourcesEClassroom
Expand Down Expand Up @@ -213,7 +214,10 @@ def document_has_content(self, document: DocumentInfo) -> bool:
def get_content(self, document: DocumentInfo, content: bytes) -> Optional[str]:
"""Get file content of docx circulars."""

result = convert_to_html(io.BytesIO(content))
def ignore_images(_image: Image) -> Dict:
return {}

result = convert_to_html(io.BytesIO(content), convert_image=ignore_images)
return typing.cast(str, result.value) # The generated HTML

@with_span(op="parse", pass_span=True)
Expand Down

0 comments on commit a442e9e

Please sign in to comment.