Skip to content

Commit

Permalink
Update metadata model
Browse files Browse the repository at this point in the history
  • Loading branch information
aturret committed Nov 27, 2024
1 parent 46f7efe commit b87d862
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ conf/*
!conf/
!conf/.gitkeep
.run/Template Python tests.run.xml
/.run/
36 changes: 18 additions & 18 deletions app/models/metadata_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def to_dict(self) -> dict:
@dataclass
class MetadataItem:
url: str
telegraph_url: str
content: str
text: str
telegraph_url: Optional[str]
content: Optional[str]
text: Optional[str]
media_files: List[MediaFile]
author: str
title: str
author_url: str
author_url: Optional[str]
category: str
message_type: MessageType
message_type: Optional[MessageType]

@staticmethod
def from_dict(obj: Any) -> "MetadataItem":
Expand Down Expand Up @@ -97,19 +97,19 @@ def from_dict(obj: Any) -> "MetadataItem":
)

def to_dict(self) -> dict:
result: dict = {}
result["url"] = from_str(self.url)
result["telegraph_url"] = ""
result["content"] = from_str(self.content)
result["text"] = from_str(self.text)
result["media_files"] = from_list(
lambda x: to_class(MediaFile, x), self.media_files
)
result["author"] = from_str(self.author)
result["title"] = from_str(self.title)
result["author_url"] = from_str(self.author_url)
result["category"] = from_str(self.category)
result["message_type"] = self.message_type.value
result: dict = {
"url": from_str(self.url),
"telegraph_url": "", "content": from_str(self.content),
"text": from_str(self.text),
"media_files": from_list(
lambda x: to_class(MediaFile, x), self.media_files
),
"author": from_str(self.author),
"title": from_str(self.title),
"author_url": from_str(self.author_url),
"category": from_str(self.category),
"message_type": self.message_type.value
}
return result


Expand Down

0 comments on commit b87d862

Please sign in to comment.