Skip to content

Conversation

@odesenfans
Copy link
Collaborator

Problem: the "/api/v0/posts.json" endpoint returns a 500 error because of an invalid parameter being used in a function (an attempt to remove the MongoDB object ID from the endpoint).

Solution: remove the object ID directly in the aggregate query.

Added a simple test to verify that the endpoint is at least working a little bit.

Problem: the "/api/v0/posts.json" endpoint returns a 500 error
because of an invalid parameter being used in a function
(an attempt to remove the MongoDB object ID from the endpoint).

Solution: remove the object ID directly in the aggregate query.

Added a simple test to verify that the endpoint is at least working
a little bit.
@odesenfans odesenfans requested a review from hoh October 6, 2022 05:21
def get_messages_by_predicate(
messages: Iterable[Dict], predicate: Callable[[Dict], bool]
) -> List[Dict]:
return [msg for msg in messages if predicate(msg)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function really useful ?
It introduces the uncommon term predicate and only contains a trivial one line of code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it a ton in another PR, just thought I'd introduce it here so that it's already in. I can rename 'predicate' to 'cond', that works as well.

@odesenfans odesenfans merged commit 6859a58 into aleph-im:dev Oct 6, 2022
@odesenfans odesenfans deleted the od-fix-500-on-posts-endpoint branch October 6, 2022 21:03
odesenfans added a commit that referenced this pull request Oct 17, 2022
Problem: the "/api/v0/posts.json" endpoint returns a 500 error
because of an invalid parameter being used in a function
(an attempt to remove the MongoDB object ID from the endpoint).

Solution: remove the object ID directly in the aggregate query.

Added a simple test to verify that the endpoint is at least working
a little bit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants