Skip to content

Conversation

@MasterFardeen15
Copy link
Contributor

@MasterFardeen15 MasterFardeen15 commented Apr 4, 2025

Description & Fixes # (issue)

Pushing course data to DB:
In db_init.py, added an argument for addCourses to add courses from json endpoint to database. Updated functions and addCourses code. I found a case in which course_code has a string of length 9.
Course data can now be pushed to the Database, course_code only accepts string of length 8 to account for course_code errors. Course data is only added to the DB, if not found in the DB.

Added logging:
Added logging with app.logger that logs information for initialization and functions in init.py file,

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

In powershell:
Run python db_init.py addCourses
In wsl:
Run python3 db_init.py addCourses

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (if a larger change)
  • New and existing unit tests pass locally with my changes

@deepsource-io
Copy link

deepsource-io bot commented Apr 4, 2025

Here's the code health analysis summary for commits 3c22324..b29287e. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython❌ Failure
❗ 2 occurences introduced
🎯 1 occurence resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Member

@RafaelCenzano RafaelCenzano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good check the few comments I added. I'd also recommend using ruff, it should be installed in the venv. you can run with ruff check to see issues. ruff format should help fix most lint errors.

db_init.py Outdated
import sys
import requests

from sqlalchemy import create_engine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing the ruff comment, this should be removed since it's not needed/used

db_init.py Outdated

if new_courses:
session.add_all(new_courses)
session.commit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for session.commit, move that into the if statement since we only need it in the if statement

db_init.py Outdated
with app.app_context():
db.create_all()

json_url = "https://raw.githubusercontent.com/quacs/quacs-data/master/semester_data/202409/catalog.json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update this function to intake the URL as an argument, should check if sys.argv[2] is present (add logic to confirm extra arguments exist). Add logic to confirm that it's a URL.

@RafaelCenzano
Copy link
Member

You should also try to merge from main too just so your code is up to date before merging

@RafaelCenzano RafaelCenzano mentioned this pull request Apr 5, 2025
11 tasks
Copy link
Member

@RafaelCenzano RafaelCenzano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MasterFardeen15
Copy link
Contributor Author

I addressed the major errors, I think it should be resolved. I'm not sure if the checks are updated.

@RafaelCenzano RafaelCenzano merged commit b29287e into LabConnect-RCOS:main Apr 13, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants