Skip to content

Commit

Permalink
prevent unnecessary .as_http_params() call
Browse files Browse the repository at this point in the history
  • Loading branch information
MHHukiewitz committed Oct 6, 2023
1 parent c452dad commit 4927c47
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/aleph/sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,14 @@ async def get_posts(
)

if not post_filter:
post_filter = PostFilter()
params = post_filter.as_http_params()
params["page"] = str(page)
params["pagination"] = str(page_size)
params = {
"page": str(page),
"pagination": str(page_size),
}
else:
params = post_filter.as_http_params()
params["page"] = str(page)
params["pagination"] = str(page_size)

async with self.http_session.get("/api/v0/posts.json", params=params) as resp:
resp.raise_for_status()
Expand Down Expand Up @@ -408,10 +412,15 @@ async def get_messages(
)

if not message_filter:
message_filter = MessageFilter()
params = message_filter.as_http_params()
params["page"] = str(page)
params["pagination"] = str(page_size)
params = {
"page": str(page),
"pagination": str(page_size),
}
else:
params = message_filter.as_http_params()
params["page"] = str(page)
params["pagination"] = str(page_size)

async with self.http_session.get(
"/api/v0/messages.json", params=params
) as resp:
Expand Down Expand Up @@ -479,8 +488,7 @@ async def watch_messages(
self,
message_filter: Optional[MessageFilter] = None,
) -> AsyncIterable[AlephMessage]:
if not message_filter:
message_filter = MessageFilter()
message_filter = message_filter or MessageFilter()
params = message_filter.as_http_params()

async with self.http_session.ws_connect(
Expand Down

0 comments on commit 4927c47

Please sign in to comment.