Merge lp:~cr3/launchpad/hwsubmissionset_search into lp:launchpad

Proposed by Marc Tardif
Status: Rejected
Rejected by: Robert Collins
Proposed branch: lp:~cr3/launchpad/hwsubmissionset_search
Merge into: lp:launchpad
Diff against target: 334 lines (+248/-3)
6 files modified
database/schema/patch-2208-74-0.sql (+12/-0)
lib/canonical/launchpad/interfaces/_schema_circular_imports.py (+1/-1)
lib/canonical/launchpad/systemhomes.py (+13/-0)
lib/lp/hardwaredb/interfaces/hwdb.py (+112/-1)
lib/lp/hardwaredb/model/hwdb.py (+16/-1)
lib/lp/hardwaredb/stories/webservice/xx-hwdb.txt (+94/-0)
To merge this branch: bzr merge lp:~cr3/launchpad/hwsubmissionset_search
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Needs Resubmitting
Review via email: mp+63767@code.launchpad.net

Description of the change

Contributing changes to expose IHWSubmissionSet.search in the API and extend it to support searching HWSubmissions by date created and date submitted. Note that the method is only available in the beta API and only accessible to people under ~hwdb-team to be consistent with the other methods in the interface.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Hi Marc,

Thanks for working on this — as a development team we often don't feel the pain from needing more API as acutely, though we are rationally aware that it exists. So it's great to see people "scratching their own itch."

I'm voting Resubmit on this because of an annoying technicality. The branch includes a schema patch, which means that the branch needs to be based on db-devel (not devel, which is what shows up as "launchpad" in a branch link) and proposed for merging into db-devel. This isn't very obvious at the moment because we just merged the two for our monthly release, but soon we'll start seeing unrelated changes show up in the diff as the two diverge and everything gets very confusing.

I didn't try to fix this for you, because having two captains on one ship is not a good way to get through a storm. Frankly I usually get out of this situation myself by getting a diff from bzr, cleaning unrelated changes out of it, and applying it to a fresh branch.

Once the merge proposal is in good working order, we proceed as follows:
 * You request a code review (like you did here). Feel free to ping me or whoever is listed as the on-call reviewer in the #launchpad-dev topic at the time.
 * You request two reviews, of type "db," from Stuart Bishop and Robert Collins respectively.
 * Stub assigns you a patch number, which you substitute for the "99" in the patch (both in the filename and in the revision table update inside the patch).

You're good to land once the patch is updated, you have an Approve vote from the code review, and you have _one_ Approve vote from the two db reviews. (If there are any disapprovals, those will have to be dealt with as well of course).

Since you probably don't have landing permission on Launchpad, you'll have to ask us to do it for you. Typically your code reviewer is a good person to handle that, but *feel free to nag* and agree on who will do it in advance if possible. In our process it's normally the author's responsibility to make sure that a branch gets landed, so we don't always remember to look for other people's approved branches that need landing. Nobody on the team will be offended if you ask them to help out with this.

Jeroen

review: Needs Resubmitting (code)
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Oh, and separately from that: the copyright notice on the patch says 2009. Probably not what you meant. :-)

Revision history for this message
Marc Tardif (cr3) wrote :

Regarding the technicality, I misunderstood one of the steps described in the DatabaseSchemaChangesProcess wiki page:

  4. If your branch also contains code changes, then request a separate code review as well.

This was the purpose of this code review whereas the step you refer to is the previous one in the wiki page:

  3. Submit a merge proposal for your branch into lp:launchpad/db-devel...

This was done separately in the following code review, I thought I needed to separate reviews:

  https://code.launchpad.net/~cr3/launchpad/hwsubmissionset_search/+merge/63768

Stub has approved the code review and provided a patch number, I updated the branch with the necessary changes and he then requested a code review from the Canonical Launchpad Engineering team. So, if I understand correctly his actions and your review comment, I now just need an Approve vote for the code review and I should be good to land.

The one thing that is still not clear is when to submit the code for review in lp:launchpad/devel after it is approved in lp:launchpad/db-devel. Is this done after getting an Approve vote from the Canonical Launchpad Engineering team on the latter branch? If so, is it the reviewer or the requester that then submits to the former branch?

Revision history for this message
Robert Collins (lifeless) wrote :

Hi marc, basically your other merge proposal is all you need; thats reviewed and going through the process, so I'm going to delete this version of the proposal.

Revision history for this message
Robert Collins (lifeless) wrote :

(actually I've rejected the *proposal* so the comments are kept, but see the other proposal for the ongoing review).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2208-74-0.sql'
2--- database/schema/patch-2208-74-0.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2208-74-0.sql 2011-06-08 12:41:54 +0000
4@@ -0,0 +1,12 @@
5+-- Copyright 2011 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+SET client_min_messages=ERROR;
9+
10+-- For IHWSubmissionSet, which can now search by date_created.
11+CREATE INDEX hwsubmission__date_created__idx ON hwsubmission USING btree (date_created);
12+
13+-- For IHWSubmissionSet, which can now search by date_submitted.
14+CREATE INDEX hwsubmission__date_submitted__idx ON hwsubmission USING btree (date_submitted);
15+
16+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 74, 0);
17
18=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
19--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2011-06-07 05:02:53 +0000
20+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2011-06-08 12:41:54 +0000
21@@ -879,7 +879,7 @@
22 patch_operations_explicit_version(
23 IHWDBApplication, 'beta', "deviceDriverOwnersAffectedByBugs", "devices",
24 "drivers", "hwInfoByBugRelatedUsers", "numDevicesInSubmissions",
25- "numOwnersOfDevice", "numSubmissionsWithDevice", "vendorIDs")
26+ "numOwnersOfDevice", "numSubmissionsWithDevice", "search", "vendorIDs")
27
28 # IHWDevice
29 patch_entry_explicit_version(IHWDevice, 'beta')
30
31=== modified file 'lib/canonical/launchpad/systemhomes.py'
32--- lib/canonical/launchpad/systemhomes.py 2011-01-21 21:42:40 +0000
33+++ lib/canonical/launchpad/systemhomes.py 2011-06-08 12:41:54 +0000
34@@ -296,6 +296,19 @@
35 """See `IHWDBApplication`."""
36 return getUtility(IHWDriverSet).all_package_names()
37
38+ def search(self, user=None, device=None, driver=None, distribution=None,
39+ distroseries=None, architecture=None, owner=None,
40+ created_before=None, created_after=None,
41+ submitted_before=None, submitted_after=None):
42+ """See `IHWDBApplication`."""
43+ return getUtility(IHWSubmissionSet).search(
44+ user=user, device=device, driver=driver,
45+ distribution=distribution, distroseries=distroseries,
46+ architecture=architecture, owner=owner,
47+ created_before=created_before, created_after=created_after,
48+ submitted_before=submitted_before,
49+ submitted_after=submitted_after)
50+
51 def getDistroTarget(self, distribution, distroseries, distroarchseries):
52 distro_targets = [
53 target for target in (
54
55=== modified file 'lib/lp/hardwaredb/interfaces/hwdb.py'
56--- lib/lp/hardwaredb/interfaces/hwdb.py 2011-02-24 15:30:54 +0000
57+++ lib/lp/hardwaredb/interfaces/hwdb.py 2011-06-08 12:41:54 +0000
58@@ -283,7 +283,9 @@
59 """
60
61 def search(user=None, device=None, driver=None, distribution=None,
62- distroseries=None, architecture=None, owner=None):
63+ distroseries=None, architecture=None, owner=None,
64+ created_before=None, created_after=None,
65+ submitted_before=None, submitted_after=None):
66 """Return the submissions matiching the given parmeters.
67
68 :param user: The `IPerson` running the query. Private submissions
69@@ -300,6 +302,14 @@
70 :param architecture: Limit results to submissions made for
71 a specific architecture.
72 :param owner: Limit results to submissions from this person.
73+ :param created_before: Limit results to submissions created
74+ before this date inclusively.
75+ :param created_after: Limit results to submissions created
76+ after this date exclusively.
77+ :param submitted_before: Limit results to submissions submitted
78+ before this date inclusively.
79+ :param submitted_after: Limit results to submissions submitted
80+ after this date exclusively.
81
82 Only one of :distribution: or :distroseries: may be supplied.
83 """
84@@ -1235,6 +1245,107 @@
85 readonly=True))
86
87 @operation_parameters(
88+ device=Reference(
89+ IHWDevice,
90+ title=u'A Device',
91+ description=(
92+ u'If specified, the result set is limited to submissions '
93+ u'containing this device.'),
94+ required=False),
95+ driver=Reference(
96+ IHWDriver,
97+ title=u'A Driver',
98+ description=(
99+ u'If specified, the result set is limited to submissions '
100+ u'containing devices that use this driver.'),
101+ required=False),
102+ distribution=Reference(
103+ IDistribution,
104+ title=u'A Distribution',
105+ description=(
106+ u'If specified, the result set is limited to submissions '
107+ u'made for this distribution.'),
108+ required=False),
109+ distroseries=Reference(
110+ IDistroSeries,
111+ title=u'A Distribution Series',
112+ description=(
113+ u'If specified, the result set is limited to submissions '
114+ u'made for the given distribution series.'),
115+ required=False),
116+ architecture=TextLine(
117+ title=u'A processor architecture',
118+ description=
119+ u'If specified, the result set is limited to sumbissions '
120+ 'made for a specific architecture.',
121+ required=False),
122+ owner=Reference(
123+ IPerson,
124+ title=u'Person',
125+ description=
126+ u'If specified, the result set is limited to sumbissions '
127+ 'from this person.',
128+ required=False),
129+ created_before=Datetime(
130+ title=u'Created Before',
131+ description=
132+ u'If specified, the result set is limited to submissions '
133+ 'created before this date inclusively',
134+ required=False),
135+ created_after=Datetime(
136+ title=u'Created After',
137+ description=
138+ u'If specified, the result set is limited to submissions '
139+ 'created after this date exclusively',
140+ required=False),
141+ submitted_before=Datetime(
142+ title=u'Created Before',
143+ description=
144+ u'If specified, the result set is limited to submissions '
145+ 'submitted before this date inclusively',
146+ required=False),
147+ submitted_after=Datetime(
148+ title=u'Created After',
149+ description=
150+ u'If specified, the result set is limited to submissions '
151+ 'submitted after this date exclusively',
152+ required=False))
153+ @call_with(user=REQUEST_USER)
154+ @operation_returns_collection_of(IHWSubmission)
155+ @export_read_operation()
156+ def search(user=None, device=None, driver=None, distribution=None,
157+ distroseries=None, architecture=None, owner=None,
158+ created_before=None, created_after=None,
159+ submitted_before=None, submitted_after=None):
160+ """Return the submissions matiching the given parmeters.
161+
162+ :param user: The `IPerson` running the query. Private submissions
163+ are returned only if the person running the query is the
164+ owner or an admin.
165+ :param device: Limit results to submissions containing this
166+ `IHWDevice`.
167+ :param driver: Limit results to submissions containing devices
168+ that use this `IHWDriver`.
169+ :param distribution: Limit results to submissions made for
170+ this `IDistribution`.
171+ :param distroseries: Limit results to submissions made for
172+ this `IDistroSeries`.
173+ :param architecture: Limit results to submissions made for
174+ a specific architecture.
175+ :param owner: Limit results to submissions from this person.
176+ :param created_before: Limit results to submissions created
177+ before this date inclusively.
178+ :param created_after: Limit results to submissions created
179+ after this date exclusively.
180+ :param submitted_before: Limit results to submissions submitted
181+ before this date inclusively.
182+ :param submitted_after: Limit results to submissions submitted
183+ after this date exclusively.
184+
185+ Only one of :distribution: or :distroseries: may be supplied.
186+ """
187+
188+ @operation_parameters(
189 bus=Choice(
190 title=u'The device bus', vocabulary=HWBus, required=False),
191 vendor_id=TextLine(
192
193=== modified file 'lib/lp/hardwaredb/model/hwdb.py'
194--- lib/lp/hardwaredb/model/hwdb.py 2011-05-27 21:12:25 +0000
195+++ lib/lp/hardwaredb/model/hwdb.py 2011-06-08 12:41:54 +0000
196@@ -294,7 +294,9 @@
197 return result_set
198
199 def search(self, user=None, device=None, driver=None, distribution=None,
200- distroseries=None, architecture=None, owner=None):
201+ distroseries=None, architecture=None, owner=None,
202+ created_before=None, created_after=None,
203+ submitted_before=None, submitted_after=None):
204 """See `IHWSubmissionSet`."""
205 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
206 args = []
207@@ -328,9 +330,22 @@
208 args.append(Distribution.id == distribution.id)
209 if distroseries is not None:
210 args.append(DistroArchSeries.distroseries == distroseries.id)
211+
212 if owner is not None:
213 args.append(HWSubmission.owner == owner.id)
214
215+ if created_before is not None:
216+ args.append(HWSubmission.date_created <= created_before)
217+
218+ if created_after is not None:
219+ args.append(HWSubmission.date_created > created_after)
220+
221+ if submitted_before is not None:
222+ args.append(HWSubmission.date_submitted <= submitted_before)
223+
224+ if submitted_after is not None:
225+ args.append(HWSubmission.date_submitted > submitted_after)
226+
227 result_set = store.find(
228 HWSubmission,
229 _userCanAccessSubmissionStormClause(user),
230
231=== modified file 'lib/lp/hardwaredb/stories/webservice/xx-hwdb.txt'
232--- lib/lp/hardwaredb/stories/webservice/xx-hwdb.txt 2011-02-13 22:54:48 +0000
233+++ lib/lp/hardwaredb/stories/webservice/xx-hwdb.txt 2011-06-08 12:41:54 +0000
234@@ -711,6 +711,100 @@
235 ...
236
237
238+=== Searching for submissions ===
239+
240+Alternatively, we can also search for hardware submissions by user:
241+
242+ >>> owner = webservice.getAbsoluteUrl('/~name12')
243+ >>> submissions = webservice.get(
244+ ... '/+hwdb?ws.op=search&owner=%s' % owner).jsonBody()
245+ >>> print submissions['total_size']
246+ 2
247+
248+ >>> owner = webservice.getAbsoluteUrl('/~name20')
249+ >>> submissions = webservice.get(
250+ ... '/+hwdb?ws.op=search&owner=%s' % owner).jsonBody()
251+ >>> print submissions['total_size']
252+ 0
253+
254+...and by device:
255+
256+ >>> device = webservice.getAbsoluteUrl('/+hwdb/+device/1')
257+ >>> submissions = webservice.named_get(
258+ ... '/+hwdb', 'search', device=device).jsonBody()
259+ >>> print submissions['total_size']
260+ 1
261+
262+...and by driver:
263+
264+ >>> driver = webservice.getAbsoluteUrl('/+hwdb/+driver/1')
265+ >>> submissions = webservice.named_get(
266+ ... '/+hwdb', 'search', driver=driver).jsonBody()
267+ >>> print submissions['total_size']
268+ 1
269+
270+...and by distribution:
271+
272+ >>> ubuntu_url = webservice.getAbsoluteUrl('/ubuntu')
273+ >>> submissions = webservice.named_get(
274+ ... '/+hwdb', 'search', distribution=ubuntu_url).jsonBody()
275+ >>> print submissions['total_size']
276+ 1
277+ >>> debian_url = webservice.getAbsoluteUrl('/debian')
278+ >>> submissions = webservice.named_get(
279+ ... '/+hwdb', 'search', distribution=debian_url).jsonBody()
280+ >>> print submissions['total_size']
281+ 0
282+
283+...and by distroseries:
284+
285+ >>> hoary_url = webservice.getAbsoluteUrl('/ubuntu/hoary')
286+ >>> submissions = webservice.named_get(
287+ ... '/+hwdb', 'search', distroseries=hoary_url).jsonBody()
288+ >>> print submissions['total_size']
289+ 1
290+ >>> warty_url = webservice.getAbsoluteUrl('/ubuntu/warty')
291+ >>> submissions = webservice.named_get(
292+ ... '/+hwdb', 'search', distroseries=warty_url).jsonBody()
293+ >>> print submissions['total_size']
294+ 0
295+
296+...and by architecture:
297+
298+ >>> submissions = webservice.named_get(
299+ ... '/+hwdb', 'search', architecture='i386').jsonBody()
300+ >>> print submissions['total_size']
301+ 1
302+ >>> submissions = webservice.named_get(
303+ ... '/+hwdb', 'search', architecture='powerpc').jsonBody()
304+ >>> print submissions['total_size']
305+ 0
306+
307+...and by date created:
308+
309+ >>> date_created = u'2007-09-11T00:00:00+00:00'
310+ >>> submissions = webservice.named_get(
311+ ... '/+hwdb', 'search', created_before=date_created).jsonBody()
312+ >>> print submissions['total_size']
313+ 1
314+ >>> submissions = webservice.named_get(
315+ ... '/+hwdb', 'search', created_after=date_created).jsonBody()
316+ >>> print submissions['total_size']
317+ 1
318+
319+...and by date submitted:
320+
321+ >>> date_submitted = u'2007-09-11T15:23:45.653316+00:00'
322+ >>> submissions = webservice.named_get(
323+ ... '/+hwdb', 'search', submitted_before=date_submitted).jsonBody()
324+ >>> print submissions['total_size']
325+ 1
326+ >>> submissions = webservice.named_get(
327+ ... '/+hwdb', 'search', submitted_after=date_submitted).jsonBody()
328+ >>> print submissions['total_size']
329+ 1
330+
331+
332 === Submission Devices ===
333
334 The table HWSubmissionDevice associates devices with submissions.