Skip to content

Commit a442e9e

Browse files
authored
Merge pull request #48 from filips123/fix-updaters-and-empty-timetable
2 parents c13e759 + b378454 commit a442e9e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

API/gimvicurnik/database/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Index,
1414
Integer,
1515
SmallInteger,
16+
String,
1617
Text,
1718
Time,
1819
func,
@@ -66,7 +67,7 @@ class Document(Base):
6667
title = Column(Text, nullable=True)
6768
hash = Column(Text, nullable=True)
6869
parsed = Column(Boolean, nullable=True)
69-
content = Column(Text, nullable=True)
70+
content = Column(String(70000), nullable=True)
7071

7172

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

171+
if times[0] is None or times[1] is None:
172+
return []
173+
170174
classrooms = list(Session.query(Classroom).order_by(Classroom.name))
171175
lessons = list(Session.query(Lesson).join(Classroom))
172176

API/gimvicurnik/updaters/eclassroom.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

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

216-
result = convert_to_html(io.BytesIO(content))
217+
def ignore_images(_image: Image) -> Dict:
218+
return {}
219+
220+
result = convert_to_html(io.BytesIO(content), convert_image=ignore_images)
217221
return typing.cast(str, result.value) # The generated HTML
218222

219223
@with_span(op="parse", pass_span=True)

0 commit comments

Comments
 (0)