Make sql reporter score null when not set

Rather than storing a 0, allow the sql reporter to store Null if no
score is set.

Also rename the alembic.ini file to be as alembic expects since it
exists in its own directory path now.

Change-Id: I5c99cd0d10d3cab7af4029b106bcd8f6c0ccbd23
This commit is contained in:
Joshua Hesketh
2017-03-28 08:40:58 +11:00
parent cd96ec00c0
commit 1d4a2c46a4
4 changed files with 27 additions and 3 deletions
@@ -0,0 +1,25 @@
"""Allow score to be null
Revision ID: 1dd914d4a482
Revises: 4d3ebd7f06b9
Create Date: 2017-03-28 08:09:32.908643
"""
# revision identifiers, used by Alembic.
revision = '1dd914d4a482'
down_revision = '4d3ebd7f06b9'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column('zuul_buildset', 'score', nullable=True,
existing_type=sa.Integer)
def downgrade():
raise Exception("Downgrades not supported")
+1 -1
View File
@@ -80,7 +80,7 @@ class SQLConnection(BaseConnection):
sa.Column('change', sa.Integer, nullable=True),
sa.Column('patchset', sa.Integer, nullable=True),
sa.Column('ref', sa.String(255)),
sa.Column('score', sa.Integer),
sa.Column('score', sa.Integer, nullable=True),
sa.Column('message', sa.TEXT()),
)
+1 -2
View File
@@ -29,8 +29,7 @@ class SQLReporter(BaseReporter):
super(SQLReporter, self).__init__(
driver, connection, config)
# TODO(jeblair): document this is stored as NULL if unspecified
# TODO(jhesketh): actually make this null in a followup change
self.result_score = config.get('score', 0)
self.result_score = config.get('score', None)
def report(self, source, pipeline, item):
"""Create an entry into a database."""