Bug 1121998 - Add the ability to retrigger all pinned jobs#787
Conversation
vaibhavmagarwal
commented
Jul 19, 2015
There was a problem hiding this comment.
I need to call selectJob() function to set the $scope.job and it has to be sequential to send correct job_ids to retriggerJob(). I know it is a bit hacky, so let me know if there is a better way.
There was a problem hiding this comment.
@vaibhavmagarwal would you like to be assigned this bug?
135e79d to
c8a85ab
Compare
There was a problem hiding this comment.
I need to call selectJob() function to set the $scope.job and it has to be sequential to send correct job_ids to retriggerJob(). I know it is a bit hacky, so let me know if there is a better way.
There was a problem hiding this comment.
I think the best way to deal with this is to convert the retrigger endpoint to a list_route and pass it a list of jobs. I prefer a single job being a special case rather than make potentially >1000 requests to the api as a consequence of a click.
c8a85ab to
fd2b269
Compare
|
Thank you for working on this! :-) |
|
@edmorley we want the "retrigger all" button to not be easily discoverable, since users can misuse it. So I have placed it in a dropdown menu. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1121998#c3 |
Ah ok :-) |
|
I'm not sure I understand the rationale to have the "retrigger all" accessible to everyone but not easily discoverable. Making things not easily discoverable on purpose sounds like a ux anti-pattern to me. We should probably come up with a policy (requests throttling maybe?) and adopt it. |
|
Given we're putting a warning before proceeding we could put it somewhere else in the pinboard (perhaps as a full button underneath the present 'Save'), but iirc @rvandermeulen had indicated a dropdown would be fine for accessibility. On the flip side we have 'Clear All' in that dropdown, and if the user misses their selection to retrigger all they would destructively clear their pinboard. :) Ryan/we could test out the current approach on stage and make it a full button if needed. |
7f683e9 to
7abe80f
Compare
There was a problem hiding this comment.
I could send this function either list of jobs or list of job_ids. I think sending it a list of jobs and then extracting whatever information we want is better. Let me know if I should just send it a list of job_ids.
a19e723 to
1158b76
Compare
|
@maurodoglio I have made the changes suggested by you. However, I am getting errors in travis for a test: https://travis-ci.org/mozilla/treeherder/builds/74163454 |
|
The error you are getting is a side effect of how QueryDict objects work in django. In the job retrigger endpoint you are retrieving the list of job ids from request.data, which retrieves only the last item if the value is a list. In your case the value returned was the string '10' and when you iterate over it you get a '1' and a '0'. The id of the jobs you are comparing in your test are 10 (expected) and 1 (actual). |
ac63d67 to
15a3b59
Compare
There was a problem hiding this comment.
@maurodoglio I noticed there is a dissimilarity between post in Django and post from AngularJS.
request.data sent from AngularJS directly gets converted to a dictionary in Django and I can't use getlist:
File "/home/vagrant/venv/local/lib/python2.7/site-packages/rest_framework/views.py", line 453, in dispatch
response = handler(request, *args, **kwargs)
File "/home/vagrant/treeherder/treeherder/webapp/api/utils.py", line 200, in use_jobs_model
return model_func(*args, jm=jm, **kwargs)
File "/home/vagrant/treeherder/treeherder/webapp/api/jobs.py", line 145, in retrigger
job_id_list = request.data.getlist("job_id_list")
AttributeError: 'dict' object has no attribute 'getlist'Whereas post from Django ( in test_jobs_api.py ) is a QueryDict object, so I have to use a getlist() method there.
|
r? @maurodoglio |
|
I just found out that request.data is a QueryDict when the content type of the request is multipart form, otherwise it's a normal dict (see the docs). In the test that was failing you are using the APIClient, which by default set the content type to multipart form. In theory the treeherder api is setup to only parse json content type, but there must be something wrong there. Anyway, you can expect request.data to be a dict if you set the request format to json in your test (see the docs for reference) |
15a3b59 to
082363f
Compare
082363f to
e3b2762
Compare
|
@maurodoglio fixed. Thanks for the docs references! |
Bug 1121998 - Add the ability to retrigger all pinned jobs