Skip to content

Commit

Permalink
Fixing Key Constraints
Browse files Browse the repository at this point in the history
Syntax on key contraints were wrong so fix them, and updated revision id's

Co-Authored-By: walshm7 <95325262+walshm7@users.noreply.github.com>
Co-Authored-By: Anthony Basnight <140746213+anthony-basnight@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 24, 2023
1 parent 86889cb commit c2f7232
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/api/db/pathway_courses_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def add_bulk_pathway_courses(self, json_data): # function is called in app.py
c_name = ' '
tokens = course.split('-')
if len(tokens) == 1:
print(tokens[0])
#print(tokens[0])
tokens = tokens[0].split()
d_code = tokens[0]
c_code = tokens[1]
Expand Down
2 changes: 2 additions & 0 deletions src/api/db/pathway_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def add_bulk_fields(self, json_data): #function is called in app.py
fields = dict()
fields['Choose one of the following'] = 'Choose one'
fields['Choose another one of the following'] = 'Choose one'
fields['Can select only one of the following to be applied to pathway'] = 'Choose one'
fields['Choose 12 credits from the following'] = 'Choose x'
fields['Choose 12 credits from the following course prefixes, ' \
'with at least 8 credit hours at, or above, ' \
Expand All @@ -72,6 +73,7 @@ def add_bulk_fields(self, json_data): #function is called in app.py
occurrence[field] += 1
for course in sub[title]:
try:
print(sub['Name'][0])
# Insert pathways and corresponding category into "pathway" table (tables/pathways.py)
transaction.execute(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def upgrade():
sa.Column('dept_code', sa.VARCHAR(length=4), nullable=False),
sa.Column('course_code', sa.VARCHAR(length=4), nullable=False),
sa.Column('course_name', sa.VARCHAR(length=255), nullable=False),
sa.PrimaryKeyConstraint('dept_code'),
sa.PrimaryKeyConstraint('course_code'),
sa.PrimaryKeyConstraint('course_name')
sa.PrimaryKeyConstraint('dept_code', 'course_code', 'course_name'),
)


Expand Down
7 changes: 2 additions & 5 deletions src/api/migrations/versions/2023-10-20_pathway_field_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# revision identifiers, used by Alembic.
revision = 'fedcba100000' # randomly created an 'unique id' with 12 hex characters
down_revision = 'efef12345678' # grab value from previous version file
down_revision = 'abcd12345678' # grab value from previous version file
branch_labels = None
depends_on = None

Expand All @@ -25,8 +25,5 @@ def upgrade():
sa.Column('course_credits', sa.VARCHAR(length=255), nullable=False),
sa.Column('desc_credit_level', sa.VARCHAR(length=255), nullable=True),
sa.Column('desc_course_level', sa.VARCHAR(length=255), nullable=True),
sa.PrimaryKeyConstraint('pathway_name'),
sa.PrimaryKeyConstraint('course_name'),
sa.PrimaryKeyConstraint('field_name'),
sa.PrimaryKeyConstraint('occurrence')
sa.PrimaryKeyConstraint('pathway_name', 'course_name','field_name', 'occurrence'),
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# revision identifiers, used by Alembic.
revision = 'efef12345678' # randomly created an 'unique id' with 12 hex characters
down_revision = 'abcd12345678' # grab value from previous version file
down_revision = 'fedcba100000' # grab value from previous version file
branch_labels = None
depends_on = None

Expand All @@ -20,6 +20,5 @@ def upgrade():
op.create_table('pathway_minors',
sa.Column('minor', sa.VARCHAR(length=255), nullable=False),
sa.Column('pathway', sa.VARCHAR(length=255), nullable=False),
sa.PrimaryKeyConstraint('minor'),
sa.PrimaryKeyConstraint('pathway')
sa.PrimaryKeyConstraint('minor', 'pathway'),
)
24 changes: 12 additions & 12 deletions src/api/tables/pathway_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ def loadFields(fields):
fields['Required'].append('Required')


if __name__ == "__main__":
with open('../../web/src/pages/pathwayV2.json') as file:
data = json.load(file)
printKeys(data)
fields = dict()
loadFields(fields)

# for i in data:
# for j in i['Pathways']:
# print(j["Name"][0], " ", i['Category Name'][0])

printPathways(data)
# if __name__ == "__main__":
# with open('../../web/src/pages/pathwayV2.json') as file:
# data = json.load(file)
# printKeys(data)
# fields = dict()
# loadFields(fields)
#
# # for i in data:
# # for j in i['Pathways']:
# # print(j["Name"][0], " ", i['Category Name'][0])
#
# printPathways(data)

0 comments on commit c2f7232

Please sign in to comment.