Skip to content

Commit

Permalink
Renaming "PCR" columns to "viral", including a DB migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
julia326 committed Jun 26, 2020
1 parent 6342600 commit bfe649e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
24 changes: 4 additions & 20 deletions app/models/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ class CoreData(db.Model, DataMixin):
antibodyTotal = db.Column(db.Integer, info={"includeInUSDaily": True})
antibodyPositive = db.Column(db.Integer, info={"includeInUSDaily": True})
antibodyNegative = db.Column(db.Integer, info={"includeInUSDaily": True})
pcrTotalTests = db.Column(db.Integer, info={"includeInUSDaily": True})
pcrPositiveTests = db.Column(db.Integer, info={"includeInUSDaily": True})
pcrNegativeTests = db.Column(db.Integer, info={"includeInUSDaily": True})
pcrPositiveCases = db.Column(db.Integer, info={"includeInUSDaily": True})
totalTestsViral = db.Column(db.Integer, info={"includeInUSDaily": True})
positiveTestsViral = db.Column(db.Integer, info={"includeInUSDaily": True})
negativeTestsViral = db.Column(db.Integer, info={"includeInUSDaily": True})
positiveCasesViral = db.Column(db.Integer, info={"includeInUSDaily": True})
totalTestsPeople = db.Column(db.Integer, info={"includeInUSDaily": True})
positiveConfirmed = db.Column(db.Integer, info={"includeInUSDaily": True})

Expand Down Expand Up @@ -203,22 +203,6 @@ def totalTestResults(self):
return self.positive
return self.positive + self.negative

@hybrid_property
def positiveTestsViral(self):
return self.pcrPositiveTests

@hybrid_property
def negativeTestsViral(self):
return self.pcrNegativeTests

@hybrid_property
def positiveCasesViral(self):
return self.pcrPositiveCases

@hybrid_property
def totalTestsViral(self):
return self.pcrTotalTests

# Converts the input to a string and returns parsed datetime.date object
@staticmethod
def parse_str_to_date(date_input):
Expand Down
42 changes: 42 additions & 0 deletions migrations/versions/0c6db53f2db2_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""empty message
Revision ID: 0c6db53f2db2
Revises: 62a65242ccf3
Create Date: 2020-06-26 17:55:26.309606
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0c6db53f2db2'
down_revision = '62a65242ccf3'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('coreData', sa.Column('negativeTestsViral', sa.Integer(), nullable=True))
op.add_column('coreData', sa.Column('positiveCasesViral', sa.Integer(), nullable=True))
op.add_column('coreData', sa.Column('positiveTestsViral', sa.Integer(), nullable=True))
op.add_column('coreData', sa.Column('totalTestsViral', sa.Integer(), nullable=True))
op.drop_column('coreData', 'pcrNegativeTests')
op.drop_column('coreData', 'pcrPositiveTests')
op.drop_column('coreData', 'pcrTotalTests')
op.drop_column('coreData', 'pcrPositiveCases')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('coreData', sa.Column('pcrPositiveCases', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('coreData', sa.Column('pcrTotalTests', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('coreData', sa.Column('pcrPositiveTests', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('coreData', sa.Column('pcrNegativeTests', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_column('coreData', 'totalTestsViral')
op.drop_column('coreData', 'positiveTestsViral')
op.drop_column('coreData', 'positiveCasesViral')
op.drop_column('coreData', 'negativeTestsViral')
# ### end Alembic commands ###

0 comments on commit bfe649e

Please sign in to comment.