Skip to content

Commit 55023d5

Browse files
committed
add default activity init
1 parent d1d3882 commit 55023d5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#logger.addHandler(sh)
4444
logger.addHandler(fh)
4545

46-
4746
## (Connexion) Flask app configuration
4847

4948
# Serve a custom version of the swagger ui (Jinja2 templates) based on the default one
@@ -59,8 +58,6 @@
5958
app.prog_engine = ProgramEngine.get_instance()
6059
app.shutdown_requested = False
6160

62-
63-
6461
## New API and web application
6562

6663
# API v2 is defined in v2.yml and its methods are in api.py
@@ -486,6 +483,16 @@ def run_server():
486483
CNNManager.get_instance()
487484
EventManager.get_instance("coderbot")
488485

486+
# Programs and Activities databases
487+
activities = TinyDB("data/activities.json")
488+
activities_collection = activities.search(query.stock == True)
489+
if len(activities_collection) == 0:
490+
activity = {
491+
name: "default"
492+
stock: True
493+
}
494+
activities.insert(activity)
495+
489496
if app.bot_config.get('load_at_start') and app.bot_config.get('load_at_start'):
490497
prog = app.prog_engine.load(app.bot_config.get('load_at_start'))
491498
prog.execute()

0 commit comments

Comments
 (0)