Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
themrphantom committed Jul 15, 2024
1 parent 5753c62 commit 55c4306
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions backend/database/Queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ def create_Links(self) -> None:
for folder in folders:
db_result: Lecture = self.session.query(
Lecture).filter_by(name=folder).first()
folder_path = f"{self.base_folder}/{folder}"
link = self.nc.create_link(folder_path)
if db_result is None:

new_Lecture = Lecture(name=folder, folder=folder_path,
link=link["link"], valid_until=link["valid_until"])
self.session.add(new_Lecture)
else:
db_result.link = link["link"]
db_result.valid_until = link["valid_until"]

# Check if the link is valid for less than 12 days
if db_result.valid_until - datetime.now() < timedelta(days=12):

folder_path = f"{self.base_folder}/{folder}"
link = self.nc.create_link(folder_path)
if db_result is None:

new_Lecture = Lecture(name=folder, folder=folder_path,
link=link["link"], valid_until=link["valid_until"])
self.session.add(new_Lecture)
else:
db_result.link = link["link"]
db_result.valid_until = link["valid_until"]

self.session.commit()
all_Lectures: List[Lecture] = self.session.query(Lecture).all()
Expand Down

0 comments on commit 55c4306

Please sign in to comment.