Merge lp:~brian-murray/arsenal/date_last_updated into lp:arsenal/trunk

Proposed by Brian Murray
Status: Merged
Merged at revision: 900
Proposed branch: lp:~brian-murray/arsenal/date_last_updated
Merge into: lp:arsenal/trunk
Diff against target: 84 lines (+35/-2)
1 file modified
reports/cbd (+35/-2)
To merge this branch: bzr merge lp:~brian-murray/arsenal/date_last_updated
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Brad Figg Pending
Review via email: mp+83876@code.launchpad.net

Description of the change

Loading the bug data for bugs that haven't changed is really unnecessary. This branch checks the date_last_updated for a bug in the json file and sees if the bug's date_last_updated is more recent than it, if it is then the bug data is retrieved.

I wanted to have another person look at it before merging it - just in case.

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

I'm not super familiar with this script yet, but conceptually the new options sound sensible. +1 from me.

review: Approve
Revision history for this message
Brad Figg (brad-figg) wrote :

On 11/29/2011 06:49 PM, Bryce Harrington wrote:
> Review: Approve
>
> I'm not super familiar with this script yet, but conceptually the new options sound sensible. +1 from me.

I'm not sure how you bzr folks normally deal with these
requests and reviews. I've emailed Brian separately with
some questions/suggestions. Overall, this is a good fix.
I'd almost prefer it to be the default rather than a
command line option but it's good either way.

Brad
--
Brad Figg <email address hidden> http://www.canonical.com

Revision history for this message
Bryce Harrington (bryce) wrote :

On Wed, Nov 30, 2011 at 02:58:24AM -0000, Brad Figg wrote:
> On 11/29/2011 06:49 PM, Bryce Harrington wrote:
> > Review: Approve
> >
> > I'm not super familiar with this script yet, but conceptually the new options sound sensible. +1 from me.
>
> I'm not sure how you bzr folks normally deal with these
> requests and reviews. I've emailed Brian separately with
> some questions/suggestions. Overall, this is a good fix.

If you go to code.launchpad.net/arsenal it shows all the branches. The
ones with the detour sign icon are ones that someone's proposed a merge
on.

  https://code.launchpad.net/arsenal/

If you click on the 'active reviews' link it shows you the merge
proposals relevant to you for reviewing.

  https://code.launchpad.net/arsenal/+activereviews

Click on the merge proposal you want to review. The green 'Diff against
target' link is useful to do a quick review of the diff. You can add a
comment and mark status to 'Approved', 'Needs Fixing', etc.

> I'd almost prefer it to be the default rather than a
> command line option but it's good either way.

I'm definitely open to trying it as the default. If it reduces our
cronjob loads against LP, that can only be a good thing.

Bryce

Revision history for this message
Brian Murray (brian-murray) wrote :

I've set updated_only to be the default and have merged my changes to trunk. Thanks for the feedback!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'reports/cbd'
2--- reports/cbd 2011-11-21 18:01:57 +0000
3+++ reports/cbd 2011-11-29 23:29:24 +0000
4@@ -72,6 +72,9 @@
5 stdo(' contains the mappings from packages to teams and from \n')
6 stdo(' milestone to milestone-date. \n')
7 stdo(' \n')
8+ stdo(' --privates Include private bugs in the results. \n')
9+ stdo(' \n')
10+ stdo(' --updated-only Only retrieve bug data for bugs which have been recently updated. \n')
11 stdo(' \n')
12 stdo(' Examples: \n')
13 stdo(' %s iso-testing-bugs.json \n' % defaults['app_name'])
14@@ -88,7 +91,7 @@
15 try:
16 cfg = defaults
17 optsShort = ''
18- optsLong = ['help', 'debug=', 'cached-lp-resources=', 'quiet']
19+ optsLong = ['help', 'debug=', 'cached-lp-resources=', 'quiet', 'privates', 'updated-only']
20 opts, args = getopt(argv[1:], optsShort, optsLong)
21
22 for opt, val in opts:
23@@ -104,6 +107,12 @@
24 if level not in Dbg.levels:
25 Dbg.levels.append(level)
26
27+ elif opt in ('--privates'):
28+ cfg['show_private_bugs'] = True
29+
30+ elif opt in ('--updated-only'):
31+ cfg['updated_only'] = True
32+
33 elif opt in ('--cached-lp-resources'):
34 cfg['cached_resources'] = val
35
36@@ -332,6 +341,14 @@
37 self.initialize()
38
39 search_start = datetime.utcnow()
40+ # old_tasks loaded from json file
41+ if self.cfg['updated_only']:
42+ last_run = json_load(self.cfg['json_file'])
43+ try:
44+ old_tasks = last_run['tasks']
45+ except KeyError:
46+ print("Old tasks not loaded as they aren't in the json file")
47+ old_tasks = {}
48 iso_tasks = {}
49
50 # For each 'search_criteria' section of the config file:
51@@ -360,9 +377,23 @@
52 #
53 if bug_number not in iso_tasks:
54 iso_tasks[bug_number] = []
55+ if self.cfg['updated_only']:
56+ if str(bug_number) in old_tasks.keys():
57+ try:
58+ # this could be way better
59+ old_bug = old_tasks['%s' % bug_number][0]
60+ except IndexError:
61+ old_bug = None
62+ # the date_last_updated info gets stripped a lot in date_to_string
63+ last_update = task.bug.date_last_updated.replace(second=0, microsecond=0, tzinfo=None)
64+ if old_bug is not None and last_update <= string_to_date(old_bug['bug']['date_last_updated']):
65+ if not self.cfg['run_quietly']:
66+ stdo("LP: #%s is being skipped as it hasn't been updated" % bug_number)
67+ iso_tasks[bug_number] = old_tasks['%s' % bug_number]
68+ continue
69
70 try:
71- if not task.bug.private:
72+ if not task.bug.private or self.cfg['show_private_bugs']:
73 t = self.get_task_info(task)
74 t['debug']['series'] = s
75 t_name = t['bug_target_name']
76@@ -546,6 +577,8 @@
77 defaults = {}
78 defaults['app_name'] = argv[0]
79 defaults['run_quietly'] = False
80+ defaults['show_private_bugs'] = False
81+ defaults['updated_only'] = False
82
83 # The cmdline processing is done here partially so the debug options
84 # can be processed right away.

Subscribers

People subscribed via source and target branches

to status/vote changes: