Spaces:
Runtime error
Runtime error
CognitiveScience
commited on
Commit
•
022a19a
1
Parent(s):
4eba62e
Update app.py
Browse files
app.py
CHANGED
@@ -84,7 +84,7 @@ with gr.Blocks() as demo:
|
|
84 |
submit = gr.Button(value="Submit Feedback")
|
85 |
|
86 |
submit.click(add_review, [name, review, comments], [data, count])
|
87 |
-
demo.load(load_data, None, [data, count])
|
88 |
|
89 |
def backup_db():
|
90 |
shutil.copyfile(DB_FILE, "./data/reviews.db")
|
@@ -94,11 +94,17 @@ def backup_db():
|
|
94 |
print("updating db")
|
95 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
scheduler = BackgroundScheduler()
|
98 |
scheduler.add_job(func=backup_db, trigger="interval", seconds=60)
|
99 |
scheduler.start()
|
100 |
|
101 |
scheduler2 = BackgroundScheduler()
|
102 |
-
scheduler2.add_job(func=
|
103 |
scheduler2.start()
|
104 |
demo.launch()
|
|
|
84 |
submit = gr.Button(value="Submit Feedback")
|
85 |
|
86 |
submit.click(add_review, [name, review, comments], [data, count])
|
87 |
+
#demo.load(load_data, None, [data, count])
|
88 |
|
89 |
def backup_db():
|
90 |
shutil.copyfile(DB_FILE, "./data/reviews.db")
|
|
|
94 |
print("updating db")
|
95 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
96 |
|
97 |
+
def load_data2():
|
98 |
+
db = sqlite3.connect(DB_FILE)
|
99 |
+
reviews, total_reviews = get_latest_reviews(db)
|
100 |
+
db.close()
|
101 |
+
return reviews, total_reviews
|
102 |
+
|
103 |
scheduler = BackgroundScheduler()
|
104 |
scheduler.add_job(func=backup_db, trigger="interval", seconds=60)
|
105 |
scheduler.start()
|
106 |
|
107 |
scheduler2 = BackgroundScheduler()
|
108 |
+
scheduler2.add_job(func=load_data2, trigger="interval", seconds=3)
|
109 |
scheduler2.start()
|
110 |
demo.launch()
|