mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Remove the status column from jobs, and update the new job status column with the previous values
This commit is contained in:
committed by
Chris Hill-Scott
parent
668e6c9716
commit
6488feaeec
@@ -300,9 +300,6 @@ class ProviderDetails(db.Model):
|
||||
active = db.Column(db.Boolean, default=False)
|
||||
|
||||
|
||||
JOB_STATUS_TYPES = ['pending', 'in progress', 'finished', 'sending limits exceeded']
|
||||
|
||||
|
||||
JOB_STATUS_PENDING = 'pending'
|
||||
JOB_STATUS_IN_PROGRESS = 'in progress'
|
||||
JOB_STATUS_FINISHED = 'finished'
|
||||
@@ -338,7 +335,6 @@ class Job(db.Model):
|
||||
unique=False,
|
||||
nullable=True,
|
||||
onupdate=datetime.datetime.utcnow)
|
||||
status = db.Column(db.Enum(*JOB_STATUS_TYPES, name='job_status_types'), nullable=False, default='pending')
|
||||
notification_count = db.Column(db.Integer, nullable=False)
|
||||
notifications_sent = db.Column(db.Integer, nullable=False, default=0)
|
||||
notifications_delivered = db.Column(db.Integer, nullable=False, default=0)
|
||||
@@ -362,7 +358,7 @@ class Job(db.Model):
|
||||
unique=False,
|
||||
nullable=True)
|
||||
job_status = db.Column(
|
||||
db.String(255), db.ForeignKey('job_status.name'), index=True, nullable=True, default='pending'
|
||||
db.String(255), db.ForeignKey('job_status.name'), index=True, nullable=False, default='pending'
|
||||
)
|
||||
|
||||
|
||||
|
||||
22
migrations/versions/0049_set_job_status.py
Normal file
22
migrations/versions/0049_set_job_status.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0049_set_job_status
|
||||
Revises: 0048_job_scheduled_time
|
||||
Create Date: 2016-08-24 13:21:51.744526
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0049_set_job_status'
|
||||
down_revision = '0048_job_scheduled_time'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("update jobs set job_status = status where job_status is null")
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
28
migrations/versions/0050_drop_jobs_status.py
Normal file
28
migrations/versions/0050_drop_jobs_status.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0050_drop_jobs_status
|
||||
Revises: 0049_set_job_status
|
||||
Create Date: 2016-08-25 15:56:31.779399
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0050_drop_jobs_status'
|
||||
down_revision = '0049_set_job_status'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('jobs', 'job_status',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=False)
|
||||
op.drop_column('jobs', 'status')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.add_column('jobs', sa.Column('status', postgresql.ENUM('pending', 'in progress', 'finished', 'sending limits exceeded', name='job_status_types'), autoincrement=False, nullable=False))
|
||||
op.alter_column('jobs', 'job_status',
|
||||
existing_type=sa.VARCHAR(length=255),
|
||||
nullable=True)
|
||||
@@ -215,15 +215,15 @@ def test_get_jobs_for_service_in_created_at_order(notify_db, notify_db_session,
|
||||
|
||||
|
||||
def test_update_job(sample_job):
|
||||
assert sample_job.status == 'pending'
|
||||
assert sample_job.job_status == 'pending'
|
||||
|
||||
sample_job.status = 'in progress'
|
||||
sample_job.job_status = 'in progress'
|
||||
|
||||
dao_update_job(sample_job)
|
||||
|
||||
job_from_db = Job.query.get(sample_job.id)
|
||||
|
||||
assert job_from_db.status == 'in progress'
|
||||
assert job_from_db.job_status == 'in progress'
|
||||
|
||||
|
||||
def test_get_scheduled_jobs_gets_all_jobs_in_scheduled_state_scheduled_before_now(notify_db, notify_db_session):
|
||||
|
||||
@@ -139,7 +139,7 @@ def test_create_unscheduled_job(notify_api, sample_template, mocker, fake_uuid):
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert resp_json['data']['id'] == fake_uuid
|
||||
assert resp_json['data']['status'] == 'pending'
|
||||
assert resp_json['data']['job_status'] == 'pending'
|
||||
assert not resp_json['data']['scheduled_for']
|
||||
assert resp_json['data']['job_status'] == 'pending'
|
||||
assert resp_json['data']['template'] == str(sample_template.id)
|
||||
@@ -176,10 +176,9 @@ def test_create_scheduled_job(notify_api, sample_template, mocker, fake_uuid):
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert resp_json['data']['id'] == fake_uuid
|
||||
assert resp_json['data']['status'] == 'pending'
|
||||
assert resp_json['data']['job_status'] == 'scheduled'
|
||||
assert resp_json['data']['scheduled_for'] == datetime(2016, 1, 2, 11, 59, 0,
|
||||
tzinfo=pytz.UTC).isoformat()
|
||||
assert resp_json['data']['job_status'] == 'scheduled'
|
||||
assert resp_json['data']['template'] == str(sample_template.id)
|
||||
assert resp_json['data']['original_file_name'] == 'thisisatest.csv'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user