Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Enhancement/allow adding removing of queues of user #83

Merged

Conversation

KPilnacek
Copy link
Contributor

@KPilnacek KPilnacek commented Aug 9, 2019

A subcommand user_assignment on the top level was created, which modifies the queues:users relationship. It allows for assignments/removals of:

  1. N users to 1 queue (elisctl user_assignment <action> -q 1 -u 1 -u 2),
  2. 1 user to N queues (elisctl user_assignment <action> -q 1 -q 2 -u 1),
  3. 1 user to 1 queue (elisctl user_assignment <action> -q 1 -u 1), as well as
  4. M user to N queues (elisctl user_assignment <action> -q 1 -q 2 -u 1 -u 2 -u 3).

If the user does (in case of assignment) have the queue, nothing happens.
If the user does not (in case of removal) has not the queue, nothing happens.

Also a elisctl user_assignment list command was added, which lists assignments of queues to users. Filters can be applied.

Closes: #82, #77

@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #83 into master will increase coverage by 0.4%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #83     +/-   ##
=========================================
+ Coverage   91.24%   91.64%   +0.4%     
=========================================
  Files          24       25      +1     
  Lines        1336     1401     +65     
=========================================
+ Hits         1219     1284     +65     
  Misses        117      117
Impacted Files Coverage Δ
elisctl/option.py 96.92% <100%> (+0.76%) ⬆️
elisctl/user.py 98.46% <100%> (ø) ⬆️
elisctl/main.py 100% <100%> (ø) ⬆️
elisctl/lib/api_client.py 89.34% <100%> (+0.08%) ⬆️
elisctl/schema/commands.py 96.29% <100%> (ø) ⬆️
elisctl/user_assignment.py 100% <100%> (ø)
elisctl/schema/upload.py 96.66% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 83e077f...5d8773d. Read the comment docs.

@KPilnacek KPilnacek force-pushed the enhancement/allow-adding-removing-of-queues-of-user branch from 0b90d0f to 66938d2 Compare August 9, 2019 11:35
Copy link
Member

@evelyn9191 evelyn9191 left a comment

Choose a reason for hiding this comment

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

Have no better suggestion for the command name. I think the future tab-completion could solve the problem with the command name length.

@option.user(required=False, help="User IDs, which the queues will be filtered by.")
@option.queue(required=False, help="Queue IDs, which the users will be filtered by.")
@click.pass_context
def list_command(ctx: click.Context, user_ids: Tuple[int], queue_ids: Tuple[int]) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

When I call user_assignment list, I intuitively expect to see a table that shows me what user is assigned to what queue, as is the case for all other list subcommands. Instead, I am getting KeyError: 'id' and need to write help for more information to find out the ID is required.
Consider making the ID not required and listing a table similar to the table shown after typing user list. I think it copies better the way the rest of elisctl is used, and the user will probably not know the IDs directly, but will have to find them out.

Copy link
Contributor Author

@KPilnacek KPilnacek Aug 9, 2019

Choose a reason for hiding this comment

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

It is bug, as it is supposed to work the proposed way (see the example produced in tests below).

elisctl user_assignment list
  id  username      queue id  queue name
----  ----------  ----------  ------------
   4  user_4               1  TestQueue
                           2  TestQueue
   5  user_5               1  TestQueue
                           2  TestQueue

Both the ids are non-required.

And I tried it myself for admin role and annotator as well, however, I cannot reproduce the error.

Please provide whole traceback and the user under which you tried this command.

Copy link
Member

Choose a reason for hiding this comment

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

(elisctl-forked) C:\PyCharm\Projects\elisctl-forked>pip install -e .

(elisctl-forked) C:\PyCharm\Projects\elisctl-forked>elisctl --version
elisctl, version 2.6.0

(elisctl-forked) C:\PyCharm\Projects\elisctl-forked>elisctl
Welcome to the elisctl interactive mode. Start with `help` and `configure`.
elis> help

Documented commands (type help <topic>):
========================================
configure  csv       queue   tools  user_assignment
connector  document  schema  user   workspace

Undocumented commands:
======================
exit  help  quit
elis> user_assignment list
KeyError: 'id'
elis>

Tried with user 13564. queue list and other commands work ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, the problem is that that queue 18994 has a user from a different organization. I'll take that into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, fixed. Please take a look again :)

Copy link
Member

Choose a reason for hiding this comment

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

It works great!

Copy link
Member

@evelyn9191 evelyn9191 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow adding/removing of queues of a user
3 participants