[copr] bkabrda-workspace: Add status for builds, enable updating and displaying data submitted by backend (86b8246)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Mon Nov 19 12:19:42 UTC 2012


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : bkabrda-workspace

>---------------------------------------------------------------

commit 86b8246ae99070481e78eac9e86edacd8d99ea7d
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Mon Nov 19 13:19:30 2012 +0100

    Add status for builds, enable updating and displaying data submitted by backend


>---------------------------------------------------------------

 ...b_setup.py => 2999fd4de2a7_initial_db_setup.py} |    9 +++++----
 wsgi/coprs/logic/builds_logic.py                   |    5 +++--
 wsgi/coprs/models.py                               |    6 +++++-
 wsgi/coprs/static/style.css                        |    6 +++++-
 wsgi/coprs/views/backend_ns/backend_general.py     |    4 ++--
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/wsgi/alembic/versions/17aef4202992_initial_db_setup.py b/wsgi/alembic/versions/2999fd4de2a7_initial_db_setup.py
similarity index 93%
rename from wsgi/alembic/versions/17aef4202992_initial_db_setup.py
rename to wsgi/alembic/versions/2999fd4de2a7_initial_db_setup.py
index 3d8ce25..8c0f24f 100644
--- a/wsgi/alembic/versions/17aef4202992_initial_db_setup.py
+++ b/wsgi/alembic/versions/2999fd4de2a7_initial_db_setup.py
@@ -1,13 +1,13 @@
-"""Initial db setup
+"""Initial DB setup
 
-Revision ID: 17aef4202992
+Revision ID: 2999fd4de2a7
 Revises: None
-Create Date: 2012-11-18 16:05:02.407902
+Create Date: 2012-11-19 13:09:17.167104
 
 """
 
 # revision identifiers, used by Alembic.
-revision = '17aef4202992'
+revision = '2999fd4de2a7'
 down_revision = None
 
 from alembic import op
@@ -50,6 +50,7 @@ def upgrade():
     sa.Column('started_on', sa.Integer(), nullable=True),
     sa.Column('ended_on', sa.Integer(), nullable=True),
     sa.Column('results', sa.Text(), nullable=True),
+    sa.Column('status', sa.Integer(), nullable=True),
     sa.Column('memory_reqs', sa.Integer(), nullable=True),
     sa.Column('timeout', sa.Integer(), nullable=True),
     sa.Column('user_id', sa.Integer(), nullable=True),
diff --git a/wsgi/coprs/logic/builds_logic.py b/wsgi/coprs/logic/builds_logic.py
index 2eb6302..f0d297d 100644
--- a/wsgi/coprs/logic/builds_logic.py
+++ b/wsgi/coprs/logic/builds_logic.py
@@ -45,6 +45,7 @@ class BuildsLogic(object):
                                    order_by(models.Build.submitted_on.asc())
         return query
 
+    @classmethod
     def get_by_ids(cls, user, ids):
         return models.Build.query.filter(models.Build.id.in_(ids))
 
@@ -58,10 +59,10 @@ class BuildsLogic(object):
         db.session.add(build)
 
     @classmethod
-    def update_from_dict(cls, user, build, upd_dict):
+    def update_state_from_dict(cls, user, build, upd_dict):
         for attr in ['results', 'started_on', 'ended_on', 'status']:
             value = upd_dict.get(attr, None)
-            if value:
+            if value != None:
                 setattr(build, attr, value)
 
         db.session.add(build)
diff --git a/wsgi/coprs/models.py b/wsgi/coprs/models.py
index 1061678..e58109f 100644
--- a/wsgi/coprs/models.py
+++ b/wsgi/coprs/models.py
@@ -134,6 +134,7 @@ class Build(db.Model, Serializer):
     started_on = db.Column(db.Integer)
     ended_on = db.Column(db.Integer)
     results = db.Column(db.Text)
+    status = db.Column(db.Integer)
     memory_reqs = db.Column(db.Integer, default = constants.DEFAULT_BUILD_MEMORY)
     timeout = db.Column(db.Integer, default = constants.DEFAULT_BUILD_TIMEOUT)
 
@@ -151,7 +152,10 @@ class Build(db.Model, Serializer):
             return 'pending'
         if not self.ended_on:
             return 'running'
-        return 'finished'
+        if self.status == 1:
+            return 'succeeded'
+
+        return 'failed'
 
     @property
     def cancelable(self):
diff --git a/wsgi/coprs/static/style.css b/wsgi/coprs/static/style.css
index df2fdfe..7e31251 100644
--- a/wsgi/coprs/static/style.css
+++ b/wsgi/coprs/static/style.css
@@ -91,10 +91,14 @@ tr.build-running {
   color: #FF6600;
 }
 
-tr.build-finished {
+tr.build-succeeded {
   color: #22DD22;
 }
 
+tr.build-failed {
+  color: #DD2222;
+}
+
 tr.build-canceled {
   color: #CDC90C;
 }
diff --git a/wsgi/coprs/views/backend_ns/backend_general.py b/wsgi/coprs/views/backend_ns/backend_general.py
index cc85ca8..0d20623 100644
--- a/wsgi/coprs/views/backend_ns/backend_general.py
+++ b/wsgi/coprs/views/backend_ns/backend_general.py
@@ -31,8 +31,8 @@ def update_builds():
         existing[build.id] = build
 
     for build in flask.request.json['builds']: # actually update existing builds
-        builds_logic.BuildsLogic.update_from_dict(None, existing[build['id']], build)
+        builds_logic.BuildsLogic.update_state_from_dict(None, existing[build['id']], build)
 
     db.session.commit()
 
-    return json.dumps({'updated_builds': len(existing)})
+    return flask.json.dumps({'updated_builds': len(existing)})



More information about the copr-devel mailing list