Merge ~jocave/checkbox-ng:save-rejected-jobs-list into checkbox-ng:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 7d0836025eb67828bf7c5002537c241c6e998e3f
Merged at revision: 7249549b3e0931f0cbb977bc452287604342f809
Proposed branch: ~jocave/checkbox-ng:save-rejected-jobs-list
Merge into: checkbox-ng:master
Diff against target: 66 lines (+24/-3)
3 files modified
plainbox/impl/providers/exporters/data/checkbox.json (+7/-0)
plainbox/impl/session/assistant.py (+8/-3)
plainbox/impl/session/state.py (+9/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Jeff Lane  Approve
Sheila Miguez (community) Approve
Review via email: mp+375095@code.launchpad.net

Description of the change

This proposes that the list of jobs rejected by the user is stored as a property of the session meta data and is included in the submission json directly. This seems like the simplest approach and makes it easy for the information to parsed by c3 and displayed directly in the private site submission pages.

Another option may have been to include the job list as some type of standalone attachment (a text file for example) that is include in the tarball. This would be easier for human to read if their preferred method of checking a submission is to download the tarball and look at the contents.

Tested that the json entries are correct when run with remote and local invocations.

To post a comment you must log in.
Revision history for this message
Sheila Miguez (codersquid) wrote :

lgtm

review: Approve
Revision history for this message
Sheila Miguez (codersquid) wrote :

In the future, will there be more metadata in the list of rejected jobs? I was wondering why it is a dict of one element and not a list of job ids.

Revision history for this message
Jonathan Cave (jocave) wrote :

It felt like it might be wise in case there was a request to include other details like which provider the job is in or the _summary.

Revision history for this message
Jeff Lane  (bladernr) wrote :

I just realized I'm directly tagged on this... LGTM too.

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1 for the list of dict, could be useful in the future.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plainbox/impl/providers/exporters/data/checkbox.json b/plainbox/impl/providers/exporters/data/checkbox.json
2index d97d1d5..3fd0b6e 100644
3--- a/plainbox/impl/providers/exporters/data/checkbox.json
4+++ b/plainbox/impl/providers/exporters/data/checkbox.json
5@@ -103,6 +103,13 @@
6 }{%- if not loop.last -%},{%- endif %}
7 {%- endfor %}
8 ],
9+ "rejected-jobs": [
10+ {%- for job_id in state.metadata.rejected_jobs %}
11+ {
12+ "full_id": "{{ job_id }}"
13+ }{%- if not loop.last -%},{%- endif %}
14+ {%- endfor %}
15+ ],
16 "category_map": {
17 {%- for cat_id, cat_name in category_map|dictsort %}
18 "{{ cat_id }}": "{{ cat_name }}"{%- if not loop.last -%},{%- endif %}
19diff --git a/plainbox/impl/session/assistant.py b/plainbox/impl/session/assistant.py
20index 50abbeb..4888730 100644
21--- a/plainbox/impl/session/assistant.py
22+++ b/plainbox/impl/session/assistant.py
23@@ -970,9 +970,14 @@ class SessionAssistant:
24 """
25 UsageExpectation.of(self).enforce()
26 self._metadata.custom_joblist = True
27- desired_job_list = [
28- self._context.get_unit(job_id, 'job') for job_id in
29- self.get_static_todo_list() if job_id in selection]
30+ desired_job_list = []
31+ rejected_job_list = []
32+ for job_id in self.get_static_todo_list():
33+ if job_id in selection:
34+ desired_job_list.append(self._context.get_unit(job_id, 'job'))
35+ else:
36+ rejected_job_list.append(job_id)
37+ self._metadata.rejected_jobs = rejected_job_list
38 self._context.state.update_desired_job_list(desired_job_list)
39
40 @raises(UnexpectedMethodCall)
41diff --git a/plainbox/impl/session/state.py b/plainbox/impl/session/state.py
42index e33c290..9f623e7 100644
43--- a/plainbox/impl/session/state.py
44+++ b/plainbox/impl/session/state.py
45@@ -85,6 +85,7 @@ class SessionMetaData:
46 self._app_blob = app_blob
47 self._app_id = app_id
48 self._custom_joblist = custom_joblist
49+ self._rejected_jobs = []
50
51 def __repr__(self):
52 """Get the representation of the session state meta-data."""
53@@ -199,6 +200,14 @@ class SessionMetaData:
54 def custom_joblist(self, value):
55 self._custom_joblist = value
56
57+ @property
58+ def rejected_jobs(self):
59+ return self._rejected_jobs
60+
61+ @rejected_jobs.setter
62+ def rejected_jobs(self, value):
63+ self._rejected_jobs = value
64+
65
66 class SessionDeviceContext:
67

Subscribers

People subscribed via source and target branches