Skip to content

Commit

Permalink
[frontend] fix Bug 1361641 - Status in build table shows wrong values
Browse files Browse the repository at this point in the history
  • Loading branch information
clime committed Sep 30, 2016
1 parent 9d921cd commit 6f6480a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 9 deletions.
80 changes: 80 additions & 0 deletions frontend/coprs_frontend/alembic/versions/149da7c4ac2f_bz1361641.py
@@ -0,0 +1,80 @@
"""Bug 1361641 - Status in build table shows wrong values
Revision ID: 149da7c4ac2f
Revises: 3a9905ed8ffd
Create Date: 2016-09-30 07:32:51.553858
"""

# revision identifiers, used by Alembic.
revision = '149da7c4ac2f'
down_revision = '3a9905ed8ffd'

from alembic import op
import sqlalchemy as sa


def upgrade():
query_functions = """
CREATE OR REPLACE FUNCTION status_to_order (x integer)
RETURNS integer AS $$ BEGIN
RETURN CASE WHEN x = 3 THEN 1
WHEN x = 6 THEN 2
WHEN x = 7 THEN 3
WHEN x = 4 THEN 4
WHEN x = 0 THEN 5
WHEN x = 1 THEN 6
WHEN x = 5 THEN 7
WHEN x = 2 THEN 8
ELSE x
END; END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION order_to_status (x integer)
RETURNS integer AS $$ BEGIN
RETURN CASE WHEN x = 1 THEN 3
WHEN x = 2 THEN 6
WHEN x = 3 THEN 7
WHEN x = 4 THEN 4
WHEN x = 5 THEN 0
WHEN x = 6 THEN 1
WHEN x = 7 THEN 5
WHEN x = 8 THEN 2
ELSE x
END; END;
$$ LANGUAGE plpgsql;
"""
op.execute(sa.text(query_functions))


def downgrade():
query_functions = """
CREATE OR REPLACE FUNCTION status_to_order (x integer)
RETURNS integer AS $$ BEGIN
RETURN CASE WHEN x = 0 THEN 0
WHEN x = 3 THEN 1
WHEN x = 6 THEN 2
WHEN x = 7 THEN 3
WHEN x = 4 THEN 4
WHEN x = 1 THEN 5
WHEN x = 5 THEN 6
WHEN x = 2 THEN 7
ELSE x
END; END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION order_to_status (x integer)
RETURNS integer AS $$ BEGIN
RETURN CASE WHEN x = 0 THEN 0
WHEN x = 1 THEN 3
WHEN x = 2 THEN 6
WHEN x = 3 THEN 7
WHEN x = 4 THEN 4
WHEN x = 5 THEN 1
WHEN x = 6 THEN 5
WHEN x = 7 THEN 2
ELSE x
END; END;
$$ LANGUAGE plpgsql;
"""
op.execute(sa.text(query_functions))
18 changes: 9 additions & 9 deletions frontend/coprs_frontend/coprs/logic/builds_logic.py
Expand Up @@ -176,26 +176,24 @@ def get_copr_builds_list(cls, copr):

if db.engine.url.drivername == "sqlite":
def sqlite_status_to_order(x):
if x == 0:
return 0
elif x == 3:
if x == 3:
return 1
elif x == 6:
return 2
elif x == 7:
return 3
elif x == 4:
return 4
elif x == 1:
elif x == 0:
return 5
elif x == 5:
elif x == 1:
return 6
elif x == 5:
return 7
return 1000

def sqlite_order_to_status(x):
if x == 0:
return 0
elif x == 1:
if x == 1:
return 3
elif x == 2:
return 6
Expand All @@ -204,8 +202,10 @@ def sqlite_order_to_status(x):
elif x == 4:
return 4
elif x == 5:
return 1
return 0
elif x == 6:
return 1
elif x == 7:
return 5
return 1000

Expand Down

0 comments on commit 6f6480a

Please sign in to comment.