refactor: code clean-up
This commit is contained in:
parent
d4bfb0a815
commit
855ec09df3
2 changed files with 5 additions and 11 deletions
12
models.py
12
models.py
|
|
@ -20,6 +20,11 @@ class NostrRelay(BaseModel):
|
||||||
def from_row(cls, row: Row) -> "NostrRelay":
|
def from_row(cls, row: Row) -> "NostrRelay":
|
||||||
return cls(**dict(row))
|
return cls(**dict(row))
|
||||||
|
|
||||||
|
class NostrEventType(str, Enum):
|
||||||
|
EVENT = "EVENT"
|
||||||
|
REQ = "REQ"
|
||||||
|
CLOSE = "CLOSE"
|
||||||
|
|
||||||
|
|
||||||
class NostrEvent(BaseModel):
|
class NostrEvent(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
|
|
@ -109,16 +114,9 @@ class NostrFilter(BaseModel):
|
||||||
if len(filter_tags) == 0:
|
if len(filter_tags) == 0:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#filter has tag
|
|
||||||
event_tag_values = [t[1] for t in event_tags if t[0] == tag_name]
|
event_tag_values = [t[1] for t in event_tags if t[0] == tag_name]
|
||||||
|
|
||||||
common_tags = [event_tag for event_tag in event_tag_values if event_tag in filter_tags]
|
common_tags = [event_tag for event_tag in event_tag_values if event_tag in filter_tags]
|
||||||
if len(common_tags) == 0:
|
if len(common_tags) == 0:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class NostrEventType(str, Enum):
|
|
||||||
EVENT = "EVENT"
|
|
||||||
REQ = "REQ"
|
|
||||||
CLOSE = "CLOSE"
|
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,6 @@ async def filter_by_tag_e_p_and_author(all_events: List[NostrEvent], author, eve
|
||||||
assert filtered_events[0].id == reply_event_id, f"Failed to filter the right event by 'author' and tags 'e' & 'p'"
|
assert filtered_events[0].id == reply_event_id, f"Failed to filter the right event by 'author' and tags 'e' & 'p'"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_fixtures(file):
|
def get_fixtures(file):
|
||||||
"""
|
"""
|
||||||
Read the content of the JSON file.
|
Read the content of the JSON file.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue