hedyhli / starcli

:sparkles: Browse trending GitHub projects from your command line
https://pypi.org/project/starcli/
MIT License
550 stars 50 forks source link

Search by Topic #48

Closed mgutz closed 4 years ago

mgutz commented 4 years ago

NO

More and more projects are tagged with relevant keywords (topic). Search by language is sometimes too broad. I would like to search within javascript language by topic react.

Command line flag --topic -t Search by topic that is used in combination with language flag.

Not sure

hedyhli commented 4 years ago

Yep, having a topic filter will be nice, thanks

hedyhli commented 4 years ago

I've just taken a look at the docs, seems like it should be quite easy to add this feature: https://docs.github.com/en/github/searching-for-information-on-github/searching-for-repositories#search-by-topic Not sure if including multiple topics would be possible

ashikjm commented 4 years ago

Hello, Could I work on this if nobody else is working?

Thanks.

hedyhli commented 4 years ago

No one is assigned, you can take this @ashikjm :) As mentioned in the issue description we change have -t foo and --topic foo to filter by topic. if you can though, feel free to add the functionality to filter by multiple topics or even exclude a topic.

ashikjm commented 4 years ago

sure @hedythedev. Thanks. :)

ashikjm commented 4 years ago

@hedythedev I have raised a PR. I had implemented the exclude topics options too but removed it as the api doesn't work as expected for the topic qualifier.

Details: I tried to follow https://docs.github.com/en/github/searching-for-information-on-github/understanding-the-search-syntax#exclude-certain-results to exclude topics. However, this works for every other qualifier (eg: language, user) but not for topic. For eg: https://api.github.com/search/repositories?q=stars:%3E=100+created:2020-07-06+language:python+-topic:deep-learning and https://api.github.com/search/repositories?q=stars:%3E=100+created:2020-07-06+language:python+topic:deep-learning give the same output (note the - before the topic qualifier in first url).

We can open a new issue to implement the exclude topic option and work on it when this is fixed by github. Thoughts?

hedyhli commented 4 years ago

We can open a new issue to implement the exclude topic option and work on it when this is fixed by github. Thoughts?

@ashikjm that will be great, thanks

I don’t think a new option would be necessary though how about excluding them like -t ‘!cli’ or something?

ashikjm commented 4 years ago

That should work fine. Shall I update the README.md with this comment?

hedyhli commented 4 years ago

Can you elaborate on what you mean? Because I doubt !cli itself would work

ashikjm commented 4 years ago

!topic actually works. In the below example, there is only repo for creation date 2020-07-06 which has deep-cleaning topic tagged. That gets filtered out when I use !deep-cleaning

`(venv) ➜ starcli -L list -l python -d 2020-07-06 ────────────────────────────────────────────────────────────────────────────────

                                                                                      google-research/torchsde                                     473 ⭐ 23 🍴 473 👀

                                                                                      Python

                                                                                      Differentiable SDE solvers with GPU support and efficient sensitivity analysis.

                                                                                      ────────────────────────────────────────────────────────────────────────────────

(venv) ➜ starcli -L list -l python -d 2020-07-06 -t '!deep-learning' (venv) ➜
(venv) ➜ `

I was trying to adding - to the topic qualifier in the code, but looks like this should be good enough.

hedyhli commented 4 years ago

ok, I see. But the thing is, if I go to https://api.github.com/search/repositories?q=topic:!deep-learning&sort=stars&order=desc according to the logic, there should be lots of repos that doesn't have deep-learning topic, but the above link doesn't return any items 🤔

hedyhli commented 4 years ago

using the search in github.com doesn't work either: https://github.com/search?q=topic%3A%21deep-learning

ashikjm commented 4 years ago

oh yes. My bad. I was thinking it is filtering out the topic as there was only one repo and it didn't print. It is actually looking for the topic named "!deep-learning" which doesn't exist and hence no results.

hedyhli commented 4 years ago

Yeah, ok no worries. As to the -QUALIFIER syntax I tried it on github.com/search and I think it actually works: https://github.com/search?q=cats+stars%3A>10+-topic%3Ajavascript&type=Repositories

but as you said doing this using the seach api doesn't work: https://api.github.com/search/repositories?q=stars:>=100+created:2020-07-06+language:python+-topic:deep-learning because google-research/torchsde does have deep learning topic

hedyhli commented 4 years ago

That said, I did find this to be working: https://api.github.com/search/repositories?q=cats+stars%3A>10+-topic%3Ajavascript

ashikjm commented 4 years ago

Yes, looks very tricky. Seems like -topic works when concatenated with a string search.