Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch query to builder pattern #50

Closed
sampottinger opened this issue Apr 17, 2023 · 1 comment · Fixed by #54
Closed

Switch query to builder pattern #50

sampottinger opened this issue Apr 17, 2023 · 1 comment · Fixed by #54

Comments

@sampottinger
Copy link
Contributor

sampottinger commented Apr 17, 2023

Part of pyOpenSci/software-submission#93, thanks @ocefpaf. Example syntax desired:

query = afscgap.query()
query.filterCommonName(eq='Pacific cod')
query.filterYear(min=2021)
results = query.execute()

or

results = afscgap.query() \
  .filterCommonName(eq='Pacific cod') \
  .filterYear(min=2021) \
  .execute()

This achieves parity with other scientific python packages in terms of patterns.

@sampottinger sampottinger changed the title Swtich query to builder pattern Switch query to builder pattern Apr 17, 2023
sampottinger added a commit that referenced this issue Apr 17, 2023
@ocefpaf
Copy link

ocefpaf commented Apr 18, 2023

I really like the new syntax:

        query = afscgap.Query(requestor=self._mock_requestor)
        query.filter_year(eq=2021)
        query.filter_latitude(eq={'$gte': 56.99, '$lte': 57.04})
        query.filter_longitude(eq={'$gte': -143.96, '$lte': -144.01})
        query.set_filter_incomplete(True)
        results = list(query.execute())

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 a pull request may close this issue.

2 participants