userIdc2024 commited on
Commit
4ae889a
·
verified ·
1 Parent(s): 1f7922f

Update src/database.py

Browse files
Files changed (1) hide show
  1. src/database.py +5 -5
src/database.py CHANGED
@@ -58,15 +58,15 @@ def insert_analysis_result(
58
  }
59
  result = collection.insert_one(document)
60
  return str(result.inserted_id)
61
- except:
62
- raise
63
 
64
  def get_all_results(limit: int = 20):
65
  """Fetch all saved results, sorted by newest"""
66
  try:
67
  client, db, collection = get_database_connection()
68
  return list(collection.find().sort("created_at", -1).limit(limit))
69
- except:
70
  return []
71
 
72
  def get_result_by_id(doc_id):
@@ -75,7 +75,7 @@ def get_result_by_id(doc_id):
75
  from bson import ObjectId
76
  client, db, collection = get_database_connection()
77
  return collection.find_one({"_id": ObjectId(doc_id)})
78
- except:
79
  return None
80
 
81
  def delete_result_by_id(doc_id):
@@ -85,5 +85,5 @@ def delete_result_by_id(doc_id):
85
  client, db, collection = get_database_connection()
86
  result = collection.delete_one({"_id": ObjectId(doc_id)})
87
  return result.deleted_count > 0
88
- except:
89
  return False
 
58
  }
59
  result = collection.insert_one(document)
60
  return str(result.inserted_id)
61
+ except Exception as e:
62
+ raise e
63
 
64
  def get_all_results(limit: int = 20):
65
  """Fetch all saved results, sorted by newest"""
66
  try:
67
  client, db, collection = get_database_connection()
68
  return list(collection.find().sort("created_at", -1).limit(limit))
69
+ except Exception:
70
  return []
71
 
72
  def get_result_by_id(doc_id):
 
75
  from bson import ObjectId
76
  client, db, collection = get_database_connection()
77
  return collection.find_one({"_id": ObjectId(doc_id)})
78
+ except Exception:
79
  return None
80
 
81
  def delete_result_by_id(doc_id):
 
85
  client, db, collection = get_database_connection()
86
  result = collection.delete_one({"_id": ObjectId(doc_id)})
87
  return result.deleted_count > 0
88
+ except Exception:
89
  return False