jira icon indicating copy to clipboard operation
jira copied to clipboard

Allow disabling searching for user on assign_issue

Open tvarney opened this issue 4 years ago • 7 comments

This adds a parameter to the _get_user_id() method which allows for selectively disabling the search for the user that said method performs. This allows for code to perform it's own user search prior to calling methods which use this method (e.g. assign_issue). This fixes an issue where the search would return the wrong user due to the ordering of users, and prevents the code from issuing duplicate search calls to the Jira server when the user has already done so.

Closes #1284

tvarney avatar Mar 03 '22 16:03 tvarney

Not super happy with the solution here, but opted for this as a way to preserve existing behavior without breaking code already using the library. Linting errors seem unrelated to my changes (they were there prior to my change as well); I can do some touch-up on them if it makes it easier to merge.

tvarney avatar Mar 03 '22 16:03 tvarney

Thanks for this.

Could I ask you to check if the proposal in #1145 would work for you? I think it may be an elegant way to handle this case.

If not I have another idea to run by you, what are you thoughts on making this a state variable for the client? Perhaps the use might look like:

jira_client = ...
jira_client.disable_internal_user_lookup()
jira_client.assign_issue(...)
jira_client.enable_internal_user_lookup()

# or perhaps with a context manager to be more explicit:
with disable_internal_user_lookup(jira_client):
    jira_client.assign_issue(...)

I can imagine that if you already know the user by key/id it may make sense to temporarily disable this.

Another option would be for us to remove the @translate_resource_args and handle it internally inside the function instead, so someone can pass in a User object, but would require a change in the use for someone to benefit from the change.

adehad avatar Mar 05 '22 22:03 adehad

The proposal in #1145 would fix the issue, but my preference would be to still have a way to disable internal searching entirely; e.g. for bulk editing of tickets where we already have an exact username it makes more sense to not attempt to search the user on every assign_issue. In that vein I've added your suggestion for a context manager because it seems like the cleanest way of handling this.

tvarney avatar Mar 10 '22 17:03 tvarney

@tvarney I think if you merge in/rebase the latest master it might fixup some of these errors

adehad avatar Apr 08 '22 15:04 adehad

just a nudge here @tvarney, would be great to include this in

adehad avatar Aug 06 '22 20:08 adehad

@tvarney Thanks for the contribtion, could you still follow up. If not also ok, though it would be nice if you could. Kr

studioj avatar Feb 09 '23 20:02 studioj