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 test case: Make sure, related topic is no unused topic #4016
base: main
Are you sure you want to change the base?
Conversation
|
fyi: The test is supposed to fail since there are actually a few related topics that don't have a single repository. Will be fixed in and should ideally be merged alongside with #4018 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was initially implemented because we were using the Octokit REST api endpoints, 1 call for each repo/user we were checking. Then I moved things over to make 1 graphql api call for every item in a collection. Is there something similar that we could do with topics?
| def topic(name) | ||
| return topics[name] if topics.key?(name) | ||
| topics[name] = client.search_repositories("topic:#{name}").total_count > 0 | ||
| @@topic_request_count += 1 | ||
| sleep client.rate_limit.resets_in if client.rate_limit.remaining == 0 | ||
| topics[name] | ||
| rescue Octokit::TooManyRequests | ||
| topics[:skip_requests] = true | ||
| topics[name] = true | ||
| end | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea here. However, I'm not sure that we want to sleep until the rate limit resets. I am not sure how long that cycle usually lasts, but we'll have to pay that price on all PRs after a rate limit is hit.
What if instead of sleeping, we set the skip_requests value when we hit 0?
| def topic(name) | |
| return topics[name] if topics.key?(name) | |
| topics[name] = client.search_repositories("topic:#{name}").total_count > 0 | |
| @@topic_request_count += 1 | |
| sleep client.rate_limit.resets_in if client.rate_limit.remaining == 0 | |
| topics[name] | |
| rescue Octokit::TooManyRequests | |
| topics[:skip_requests] = true | |
| topics[name] = true | |
| end | |
| def topic(name) | |
| return topics[name] if topics.key?(name) | |
| if client.rate_limit.remaining > 0 | |
| @@topic_request_count += 1 | |
| topics[name] = client.search_repositories("topic:#{name}").total_count > 0 | |
| else | |
| topics[:skip_requests] = true | |
| topics[name] = true | |
| end | |
| topics[name] | |
| rescue Octokit::TooManyRequests | |
| topics[:skip_requests] = true | |
| topics[name] = true | |
| end | |
The rescue might be redundant in this case, but I'm leaving it in there to match what we're doing in other places. Although, I like this pattern better. If you had the time to modify the rest of the methods to match this, and if it works, I'd be +1 for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, what skip_requests does, is to only check topics until the rate limit is reached and leave the rest unchecked, so we don't have to wait? Doesn't sound very trustworthy to me, to be honest. However, this might be solved by a GraphQL implementation—I definitely look into that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wrote all this a very long time ago and I think I was doing it so that we could simply get passed the failing checks, then I swapped over to the graphql stuff and all of this was no longer a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely possible via GraphQL. I'm implementing it right now. Stay tuned!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong. I did a little fiddling, and it turns out that the API doesn't expect the topic's repositories property to be accessed if it's not curated. Is there a way around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can access the totalCount on the repositories property for topics that don't have any repos still:
query {
topic(name:"kart-racing") {
repositories{
totalCount
}
relatedTopics {
id
}
}
}result:
{
"data": {
"topic": {
"repositories": {
"totalCount": 0
},
"relatedTopics": []
}
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are right. My query was:
query {
config: topic(name:"config") {
repositories{
totalCount
}
relatedTopics {
id
}
}
}But it's not that 5,819,971 repositories might be too much, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone have any idea what's so special about "config"?
Co-authored-by: Justin Kenyon <kenyonj@github.com>
|
I couldn't quite follow whether the conversation on the test changes resolved to a good state - @kenyonj can you take a quick peek and merge if you're happy? Thx |
|
@ahpook No, unfortunately, there's still a problem with the topic "config" and I just can't figure out why—it doesn't seem to be a reserved word or the like. |
|
@ahpook I excluded |
test/topics_test.rb
Outdated
| # carry.merge(related_topics) | ||
| #end | ||
| #cache_topics_exist_check!(all_related_topics) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to stay commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I only knew 😅
If in doubt, this apparently can be deleted 🤷🏻♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still used in https://github.com/shaedrich/explore/blob/topics_test/test/topics_test.rb#L168, so I suppose, that's okay 🤔
|
Classic Ruby stuff 💎 |
Should we worry about that or are we fine without |



As per 7d2ffe5#r1069478838
Please confirm this pull request meets the following requirements:
Which change are you proposing?
Editing an existing topic or collection
I'm suggesting these edits to an existing topic or collection:
*.png, square, dimensions 288x288, size <= 75 kB)index.md)Curating a new topic or collection
https://github.com/topics/[NAME]orhttps://github.com/collections/[NAME])*.pngimage (if applicable) andindex.mdindex.mdconform to the Style Guide and API docs: https://github.com/github/explore/tree/main/docsSomething that does not neatly fit into the binary options above
As per #3487 (comment)
Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.