Spaces:
Runtime error
Runtime error
update the way to reindex
Browse files- src/indexing.py +5 -1
src/indexing.py
CHANGED
@@ -17,7 +17,9 @@ collection = db.questionAndAnswers
|
|
17 |
|
18 |
|
19 |
def insertQuestionAndAnswers(questionAndAnswers):
|
20 |
-
|
|
|
|
|
21 |
|
22 |
def deleteByUserId(user_id: str):
|
23 |
return collection.delete_many({'user_id': user_id})
|
@@ -50,7 +52,9 @@ def indexData(sheet_id: str, sheet_name: str):
|
|
50 |
}
|
51 |
questionAndAnswers.append(questionAndAnswer)
|
52 |
deleteByUserId(sheet_id)
|
|
|
53 |
insertQuestionAndAnswers(questionAndAnswers)
|
|
|
54 |
# for index, article in enumerate(data):
|
55 |
# if(index< 6580):
|
56 |
# continue;
|
|
|
17 |
|
18 |
|
19 |
def insertQuestionAndAnswers(questionAndAnswers):
|
20 |
+
for index, questionAndAnswer in enumerate(questionAndAnswers):
|
21 |
+
print(f"""inserting {index}: {questionAndAnswer['question']}""")
|
22 |
+
collection.insert_one(questionAndAnswer)
|
23 |
|
24 |
def deleteByUserId(user_id: str):
|
25 |
return collection.delete_many({'user_id': user_id})
|
|
|
52 |
}
|
53 |
questionAndAnswers.append(questionAndAnswer)
|
54 |
deleteByUserId(sheet_id)
|
55 |
+
print(f'deleted dta of sheet {sheet_id}')
|
56 |
insertQuestionAndAnswers(questionAndAnswers)
|
57 |
+
|
58 |
# for index, article in enumerate(data):
|
59 |
# if(index< 6580):
|
60 |
# continue;
|