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

Add sort_order parameter for search api #645

Merged
merged 4 commits into from
Jun 24, 2022
Merged

Add sort_order parameter for search api #645

merged 4 commits into from
Jun 24, 2022

Conversation

mirkolenz
Copy link
Contributor

As discussed in #597, Twitter added the new field sort_order to their search endpoints. This PR is a first attempt to include this new parameter in twarc. In my tests, setting sort_order="relevancy" gave a different ordering of results, thus I think it should work.

One comment on my code: Initially, I wanted to add this new parameter to the command_line_search_options decorator. However, it is also used for the counts endpoint, which does not provide the parameter sort_order. Thus, I included the click option for every relevant function individually.

I am happy to modify my code according to your recommendations 😃

@mirkolenz
Copy link
Contributor Author

mirkolenz commented Jun 22, 2022

I forgot to mention: I did not yet update the docs and tests as I wanted to wait for feedback on the actual implementation. As soon as that is cleared, I will update them as well.

Copy link
Contributor

@SamHames SamHames left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to submit a PR. This looks good so far, I've just noted one little added mistake in the docstrings.

It would be great if you could add a test case for the sort parameter as well - maybe just by expanding https://github.com/DocNow/twarc/blob/main/test_twarc2.py#L102 with an additional case for the new parameter? Let me know if you want any help with that.

@igorbrigadir might have some more specific thoughts about how to handle the CLI parameters though.

twarc/client2.py Outdated Show resolved Hide resolved
@SamHames
Copy link
Contributor

Sorry, I missed your comment about adding the tests later - I'm happy to merge and release once there's a test unless there's any objections.

@mirkolenz
Copy link
Contributor Author

I have updated/fixed the docstrings, updated the method you linked via a pytest.parametrize option, and added docs for the new feature.

@igorbrigadir
Copy link
Contributor

Awesome! thanks so much! The --sort-order is fine that way, we can clean it up or refactor it later! All good to go!

@igorbrigadir igorbrigadir merged commit 4b72913 into DocNow:main Jun 24, 2022
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.

3 participants