More efficient name-to-id translation#555
Conversation
858837b to
e9b95e0
Compare
dblock
left a comment
There was a problem hiding this comment.
Thanks, this is a good change. However you should implement it in a way that does not change the existing functionality.
I think we don't want to have to pass the limit all over the place, but to configure it globally and per/client, so follow the existing settings pattern to add it. The default should be no changes, making the API calls as today.
7b1bf50 to
8097e0b
Compare
It's only passed in the one spot, and should probably remain there; if we defer until we're inside
Amended, pushed. How do we feel about the name The config change does create an unusual codependency between |
51dec13 to
e76942d
Compare
There was a problem hiding this comment.
We are still changing behavior by passing in a page size (100) by default. The code should not be passing anything into limit as before by default to avoid breaking backwards compatibility. I understand this may be the Slack default, or we have default_page_size, but we are relying on this knowledge here.
Stepping back, I propose we add id_for_page_size instead of conversations_id_page_size and implement this inside id_for. It will be simpler and cleaner. Unless you have a reason why this may be a bad idea?
And I'd like to be able to write this, overriding whatever the global id_for_page_size was set to (needs tests):
conversations_id(channel: 'C1234', limit: 10)This will require passing the limit through, we may want to pass all of options down or add a single limit/page_size parameter.
Sorry to be a pest, hang in here with me :)
e76942d to
4a87569
Compare
I think you refer to theh explicit 100 I used to appease the test suite? If so, I'd overlooked the fact we were already doing some stubbing there. Oops! Switched to a stub - no more 100.
My only major concern is hypothetical: there might be scenarios where no single page size is good for all translations using
I like it! Coming shortly... |
Pull Request Test Coverage Report for Build 15024095954Details
💛 - Coveralls |
9c11bec to
1d767ca
Compare
|
I've added a couple commits to implement the requested |
1d767ca to
a6a86d1
Compare
dblock
left a comment
There was a problem hiding this comment.
Much better!
Add tests for the default value and I think we need to rename things.
| :conversations_list, | ||
| :channels, | ||
| 'channel_not_found', | ||
| enum_method_options: { limit: limit } |
There was a problem hiding this comment.
I think either we just add one more limit parameter to the already long list of arguments or change the signature to just id_for(options)? WDYT?
If you think both are a bad idea, at a minimum let's rename enum_method_options to just options to be future-proof?
Do the changes in the first new commit suffice? I'm not 100% sure on where these should go otherwise. Tests for page size are not present near the other config value tests.
While considering this I noticed a Problem; these methods are often used inside endpoint methods which - as a result of our change - unintentionally pass A single The second new commit contains changes related to the above issues. |
3cb8c82 to
39b2ece
Compare
- avoid unintentional parameter forwarding via limit -> id_limit - switch to keyword parameters - deduce error text instead of using argument - enum_method_options -> options
39b2ece to
1f777a9
Compare
dblock
left a comment
There was a problem hiding this comment.
Are we changing default behavior for default page size still, or does it get called with default_page_size anyway today?
| end | ||
|
|
||
| it 'translates a channel that starts with a #' do | ||
| expect(conversations).to receive(:conversations_list).with(limit: 100) |
There was a problem hiding this comment.
This is a change in default behavior isn't it? This test doesn't pass without the changes.
There was a problem hiding this comment.
Ah, yes - the old code relies on the default from within the paginator. Hash#compact should suffice to fix this if the defaults are nil; see what you think
451fa7d to
307558b
Compare
|
Something funky going on in tests - lots of followed by a segfault. Don't have time to dig in at the moment; if you do and hit paydirt, please let me know! |
9dd0007 to
4a1783d
Compare
c97187f to
c6e0869
Compare
|
Modified your CI so e.g. when ruby-head segfaults during tests Coveralls doesn't panic over the missing test info; ready for re-review |
dblock
left a comment
There was a problem hiding this comment.
Looks great! Thanks for hanging in here with me.
Not at all; thanks for ensuring additions to this gem are appropriately refined! |
The
conversations_idmethod paginates with default options over conversations.list responses to find a conversation with a particular name. Theconversations.listendpoint has a Tier 2 rate limit, which - when combined with the low default page size - can cause just a single call in a workspace with 2000+ channels to result in rate limiting. This change enables use of non-default page sizes withinconversations_id(andid_for, more generally), thus reducing the risk of rate limiting within such workspaces.