Browse Source

Fix populate of bulk data

Peter Justin 7 years ago
parent
commit
fc8359a111
1 changed files with 8 additions and 4 deletions
  1. 8 4
      flaskbb/cli/main.py

+ 8 - 4
flaskbb/cli/main.py

@@ -204,15 +204,19 @@ def populate(bulk_data, test_data, posts, topics, force, initdb):
         create_test_data()
         create_test_data()
 
 
     if bulk_data:
     if bulk_data:
+        click.secho("[+] Adding a lot of test data...", fg="cyan")
         timer = time.time()
         timer = time.time()
-        topic_count, post_count = insert_bulk_data(int(topics), int(posts))
+        rv = insert_bulk_data(int(topics), int(posts))
+        if not rv and not test_data:
+            create_test_data()
+            rv = insert_bulk_data(int(topics), int(posts))
         elapsed = time.time() - timer
         elapsed = time.time() - timer
-        click.secho("[+] It took {} seconds to create {} topics and {} posts"
-                    .format(elapsed, topic_count, post_count), fg="cyan")
+        click.secho("[+] It took {:.2f} seconds to create {} topics and {} "
+                    "posts.".format(elapsed, rv[0], rv[1]), fg="cyan")
 
 
     # this just makes the most sense for the command name; use -i to
     # this just makes the most sense for the command name; use -i to
     # init the db as well
     # init the db as well
-    if not test_data:
+    if not test_data and not bulk_data:
         click.secho("[+] Populating the database with some defaults...",
         click.secho("[+] Populating the database with some defaults...",
                     fg="cyan")
                     fg="cyan")
         create_default_groups()
         create_default_groups()