Skip to content

Commit

Permalink
added null check and handling for append_doc_group and remove_doc_group
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwell-Lindsey committed Feb 26, 2024
1 parent c635c7e commit f9f6dd8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ai_ta_backend/vector_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,8 @@ def append_doc_group(self, course_name: str, doc: MaterialDocument, doc_group: s
"""
Append a document group to a document's doc_groups array.
"""
if doc.doc_groups is None:
doc.doc_groups = []
if doc_group not in doc.doc_groups:
doc.doc_groups.append(doc_group)
self.add_documents_to_doc_group(course_name, doc)
Expand All @@ -1753,6 +1755,8 @@ def remove_doc_group(self, course_name: str, doc: MaterialDocument, doc_group: s
"""
Remove a document group from a document's doc_groups array.
"""
if doc.doc_groups is None:
doc.doc_groups = []
if doc_group in doc.doc_groups:
doc.doc_groups.remove(doc_group)
self.add_documents_to_doc_group(course_name, doc)
Expand Down

0 comments on commit f9f6dd8

Please sign in to comment.