broadfield-dev commited on
Commit
97a599a
·
verified ·
1 Parent(s): 588e258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -36,7 +36,6 @@ def load_feeds_in_background():
36
  def index():
37
  global loading_complete, last_update_time
38
 
39
- # Check if the database needs to be loaded (first time or empty)
40
  db_exists = os.path.exists("chroma_db") and vector_db.get().get('documents')
41
  if not db_exists:
42
  loading_complete = False
@@ -44,13 +43,14 @@ def index():
44
  download_from_hf_hub()
45
  threading.Thread(target=load_feeds_in_background, daemon=True).start()
46
  elif not loading_complete:
47
- pass # Let background loading continue
48
  else:
49
  loading_complete = True
50
 
51
  try:
52
- # Retrieve all articles from Chroma DB
53
  all_docs = vector_db.get(include=['documents', 'metadatas'])
 
 
54
  if not all_docs.get('metadatas'):
55
  logger.info("No articles in DB yet")
56
  return render_template("index.html", categorized_articles={}, has_articles=False, loading=not loading_complete)
 
36
  def index():
37
  global loading_complete, last_update_time
38
 
 
39
  db_exists = os.path.exists("chroma_db") and vector_db.get().get('documents')
40
  if not db_exists:
41
  loading_complete = False
 
43
  download_from_hf_hub()
44
  threading.Thread(target=load_feeds_in_background, daemon=True).start()
45
  elif not loading_complete:
46
+ pass
47
  else:
48
  loading_complete = True
49
 
50
  try:
 
51
  all_docs = vector_db.get(include=['documents', 'metadatas'])
52
+ total_docs = len(all_docs['documents']) if all_docs.get('documents') else 0
53
+ logger.info(f"Total articles in DB: {total_docs}")
54
  if not all_docs.get('metadatas'):
55
  logger.info("No articles in DB yet")
56
  return render_template("index.html", categorized_articles={}, has_articles=False, loading=not loading_complete)