Merge lp:~gmb/launchpad/jobbifiy-bug-heat-calculations-509193 into lp:launchpad/db-devel
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Merged at revision: | not available | ||||
| Proposed branch: | lp:~gmb/launchpad/jobbifiy-bug-heat-calculations-509193 | ||||
| Merge into: | lp:launchpad/db-devel | ||||
| Diff against target: |
570 lines (+483/-1) 11 files modified
cronscripts/calculate-bug-heat.py (+33/-0) database/schema/security.cfg (+8/-0) lib/canonical/config/schema-lazr.conf (+9/-0) lib/lp/bugs/configure.zcml (+11/-0) lib/lp/bugs/interfaces/bugjob.py (+66/-0) lib/lp/bugs/model/bugheat.py (+54/-0) lib/lp/bugs/model/bugjob.py (+148/-0) lib/lp/bugs/scripts/bugheat.py (+3/-1) lib/lp/bugs/tests/test_bugheat.py (+95/-0) lib/lp/bugs/tests/test_bugjob.py (+55/-0) lib/lp/services/job/interfaces/job.py (+1/-0) |
||||
| To merge this branch: | bzr merge lp:~gmb/launchpad/jobbifiy-bug-heat-calculations-509193 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Paul Hummer (community) | code | 2010-01-21 | Approve on 2010-01-21 |
|
Review via email:
|
|||
Commit Message
Add infrastructure to allow the Bug Tracker to use the Jobs system for task. Also add specific infrastructure for using the Jobs system to update bug heat.
| Graham Binns (gmb) wrote : | # |
| Paul Hummer (rockstar) wrote : | # |
Hi Graham-
This branch looks good. I have a few comments.
=== added file 'cronscripts/
--- cronscripts/
+++ cronscripts/
@@ -0,0 +1,33 @@
+#!/usr/
+#
+# Copyright 2009 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+# pylint: disable-msg=W0403
+
It's 2010 now. :)
=== added file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -0,0 +1,158 @@
+# Copyright 2009 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Job classes related to BugJobs are in here."""
+
+__metaclass__ = type
+__all__ = [
+ 'BugJob',
+ ]
+
+import simplejson
+
+from sqlobject import SQLObjectNotFound
+from storm.base import Storm
+from storm.expr import And
+from storm.locals import Int, Reference, Unicode
+
+from zope.component import getUtility
+from zope.interface import implements
+from zope.security.proxy import removeSecurityProxy
+
+from canonical.
+from canonical.
+ DEFAULT_FLAVOR, IStoreSelector, MAIN_STORE, MASTER_FLAVOR)
+
+from lazr.delegates import delegates
+
+from lp.bugs.
+from lp.bugs.model.bug import Bug
+from lp.services.
+from lp.services.
+
+
+class BugJob(Storm):
+ """Base class for jobs related to Bugs."""
+
+ implements(IBugJob)
+
+ __storm_table__ = 'BugJob'
+
+ id = Int(primary=True)
+
+ job_id = Int(name='job')
+ job = Reference(job_id, Job.id)
+
+ bug_id = Int(name='bug')
+ bug = Reference(bug_id, Bug.id)
+
+ job_type = EnumCol(
+
+ _json_data = Unicode(
+
+ @property
+ def metadata(self):
+ return simplejson.
+
+ def __init__(self, bug, job_type, metadata):
+ """Constructor.
+
+ :param bug: The proposal this job relates to.
+ :param job_type: The BugJobType of this job.
+ :param metadata: The type-specific variables, as a JSON-compatible
+ dict.
+ """
+ Storm._
+ json_data = simplejson.
+ self.job = Job()
+ self.bug = bug
+ self.job_type = job_type
+ # XXX AaronBentley 2009-01-29 bug=322819: This should be a bytestring,
+ # but the DB representation is unicode.
+ self._json_data = json_data.
+
+ @classmethod
+ def get(cls, key):
+ """Return the instance of this class whose key is supplied."""
+ store = getUtility(
+ instance = store.get(cls, key)
+ if instance is None:
+ raise SQLObjectNotFound(
+ 'No occurrence of %s has key %s' % (cls.__name__, key))
+ return instance
+
+
+class BugJobDerived(
+ """Inte...
| Graham Binns (gmb) wrote : | # |
On Thu, Jan 21, 2010 at 07:17:01PM -0000, Paul Hummer wrote:
> Review: Needs Information code
> Hi Graham-
>
> This branch looks good. I have a few comments.
>
> === added file 'cronscripts/
> --- cronscripts/
> +++ cronscripts/
> @@ -0,0 +1,33 @@
> +#!/usr/
> +#
> +# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +# pylint: disable-msg=W0403
> +
>
> It's 2010 now. :)
>
Erk. Fixed.
> === added file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -0,0 +1,158 @@
> +# Copyright 2009 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""Job classes related to BugJobs are in here."""
> +
> +__metaclass__ = type
> +__all__ = [
> + 'BugJob',
> + ]
> +
> +import simplejson
> +
> +from sqlobject import SQLObjectNotFound
> +from storm.base import Storm
> +from storm.expr import And
> +from storm.locals import Int, Reference, Unicode
> +
> +from zope.component import getUtility
> +from zope.interface import implements
> +from zope.security.proxy import removeSecurityProxy
> +
> +from canonical.
> +from canonical.
> + DEFAULT_FLAVOR, IStoreSelector, MAIN_STORE, MASTER_FLAVOR)
> +
> +from lazr.delegates import delegates
> +
> +from lp.bugs.
> +from lp.bugs.model.bug import Bug
> +from lp.services.
> +from lp.services.
> +
> +
> +class BugJob(Storm):
> + """Base class for jobs related to Bugs."""
> +
> + implements(IBugJob)
> +
> + __storm_table__ = 'BugJob'
> +
> + id = Int(primary=True)
> +
> + job_id = Int(name='job')
> + job = Reference(job_id, Job.id)
> +
> + bug_id = Int(name='bug')
> + bug = Reference(bug_id, Bug.id)
> +
> + job_type = EnumCol(
> +
> + _json_data = Unicode(
> +
> + @property
> + def metadata(self):
> + return simplejson.
> +
> + def __init__(self, bug, job_type, metadata):
> + """Constructor.
> +
> + :param bug: The proposal this job relates to.
> + :param job_type: The BugJobType of this job.
> + :param metadata: The type-specific variables, as a JSON-compatible
> + dict.
> + """
> + Storm._
> + json_data = simplejson.
> + self.job = Job()
> + self.bug = bug
> + self.job_type = job_type
> + # XXX AaronBentley 2009-01-29 bug=322819: This should be a bytestring,
> + # but the DB representation is unicode.
> + self._json_data = json_data.
> +
> + @classmethod
> + def get(cls, key):
> + """Return the instance of this class whose key is supplied."""
> + store = getUtility(ISt...

This branch adds the necessary interfaces and implementations to the bug
tracker to:
a. Allow us to use the Jobs system for Bug-related tasks generally and
b. Allow us to use the Jobs system to update bug heat specifically.
A lot of the work for the Jobs system has been cribbed from how it's
used in Codehosting, but we've pared it down to make sure that we don't
repeat stuff that's defined elsewhere. A full list of the changes we've
made is below.
We've also added a cronscript to run the CalculateBugHea tJobs.
== List of changes ==
=== cronscripts/ calculate- bug-heat. py ===
- We've added a cronscript to run pending CalculateBugHea tJobs.
=== database/ schema/ security. cfg ===
- We've added permissions for the CalculateBugHeatJob runner.
=== lib/canonical/ config/ schema- lazr.conf ===
- We've added config options for the CalculateBugHeatJob runner.
=== lib/lp/ bugs/configure. zcml ===
- We've added ZCML configuration for the CalculateBugHea tJobs.
=== lib/lp/ bugs/interfaces /bugjob. py ===
- We've added the following interfaces: atJob: A base interface for bug heat calculation atJobSource: An interface for acquiring BugHeatJobs.
- IBugJob: A base Job interface for Bugs.
- ICalculateBugHe
job.
- ICalculateBugHe
ICalculate
=== lib/lp/ bugs/model/ bugheat. py ===
- We've added implementation for CalculateBugHea tJob. This uses a lator to calculate the bug heat and then calls
BugHeatCalcu
Bug.setHeat() to set the bug's heat.
=== lib/lp/ bugs/model/ bugjob. py ===
- We've added the following classes (cribbed largely from Codehosting):
- BugJob: Provides a base class for all bug jobs.
- BugJobDerived: Provides an intermediate class for deriving from
BugJob, so that a lot of the job-generic work can be done here
rather than others having to reproduce more boilerplate.
=== lib/lp/ bugs/scripts/ bugheat. py ===
- We've added BugHeatCalculator to the __all__ for this module in order
to fix some lint.
=== lib/lp/ bugs/tests/ test_bugheat. py ===
- We've added unit tests for the CalculateBugHeatJob class.
=== lib/lp/ bugs/tests/ test_bugjob. py ===
- We've added unit tests for the generic BugJob classes.
=== lib/lp/ services/ job/interfaces/ job.py ===
- We've added IJobSource to the __all__ for this module in order to
fix some lint.