[Pkg-debile-commits] [debile-master] 58/126: update models
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:56:14 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch scan-build-html
in repository debile-master.
commit a9672805b9bf6c377091c270032915129c490433
Author: Paul Tagliamonte <tag at pault.ag>
Date: Sat Jun 1 20:57:45 2013 -0400
update models
---
lucy/models/job.py | 20 +++++++++++++++++---
lucy/models/report.py | 11 ++++++++++-
lucy/models/source.py | 12 ++++++++++++
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/lucy/models/job.py b/lucy/models/job.py
index bdfc551..5e1a004 100644
--- a/lucy/models/job.py
+++ b/lucy/models/job.py
@@ -8,7 +8,8 @@ class Job(LucyObject):
_type = 'jobs'
def __init__(self, type, package, package_type, arch, suite,
- builder=None, finished_at=None, assigned_at=None, **kwargs):
+ builder=None, finished_at=None, assigned_at=None,
+ source=None, **kwargs):
from lucy.models.source import Source
from lucy.models.binary import Binary
@@ -17,18 +18,31 @@ class Job(LucyObject):
raise ValueError("package_type needs to be binary or source")
if package_type == "source":
- package = Source.load(package)['_id']
+ package = Source.load(package)
+ if source is None:
+ source = package['_id']
if package_type == "binary":
- package = Binary.load(package)['_id']
+ package = Binary.load(package)
+ if source is None:
+ source = package['source']
+
+ if package is None:
+ raise ValueError("Bad package")
+
+ package = package['_id']
if builder:
builder = Machine.load(builder)['_id']
+ if source is None:
+ raise ValueError("Bad source :(")
+
super(Job, self).__init__(
type=type,
arch=arch,
suite=suite,
+ source=source,
package=package,
builder=builder,
finished_at=finished_at,
diff --git a/lucy/models/report.py b/lucy/models/report.py
index 67943ba..93dd531 100644
--- a/lucy/models/report.py
+++ b/lucy/models/report.py
@@ -9,7 +9,8 @@ class Report(LucyObject):
_type = 'reports'
def __init__(self, report, builder, package,
- package_type, job, failed, type=None, **kwargs):
+ package_type, job, failed,
+ source=None, type=None, **kwargs):
if package_type not in ["source", "binary"]:
raise ValueError("Bad package type")
@@ -18,12 +19,16 @@ class Report(LucyObject):
if package_type == 'source':
try:
loaded_package = Source.load(package)
+ if source is None:
+ source = loaded_package['_id']
except KeyError:
pass
if package_type == 'binary':
try:
loaded_package = Binary.load(package)
+ if source is None:
+ source = loaded_package['source']
except KeyError:
pass
@@ -37,7 +42,11 @@ class Report(LucyObject):
if type is None:
type = job['type']
+ if source is None:
+ raise ValueError("No source :(")
+
super(Report, self).__init__(package_type=package_type,
+ source=source,
builder=builder,
package=loaded_package['_id'],
report=report,
diff --git a/lucy/models/source.py b/lucy/models/source.py
index 3fadc07..68f0fce 100644
--- a/lucy/models/source.py
+++ b/lucy/models/source.py
@@ -1,6 +1,7 @@
from lucy.models import LucyObject
from lucy.models.user import User
from lucy.models.job import Job
+import lucy.core
class Source(LucyObject):
@@ -30,3 +31,14 @@ class Source(LucyObject):
from lucy.models.binary import Binary
for x in Binary.query({"source": self['_id']}):
yield x
+
+ def get_job_status(self):
+ db = lucy.core.db
+ total = db.jobs.find({
+ "source": self['_id']
+ }).count()
+ unfinished = db.jobs.find({
+ "source": self['_id'],
+ "finished_at": None
+ }).count()
+ return (total, unfinished)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list