From e5d8d3c0cf00d23a9a51027f72a7933853736232 Mon Sep 17 00:00:00 2001
From: Arthur Lu <learthurgo@gmail.com>
Date: Fri, 28 Feb 2025 20:12:23 +0000
Subject: [PATCH] add basic data generation

---
 app/database/generate_data_basic.py | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 app/database/generate_data_basic.py

diff --git a/app/database/generate_data_basic.py b/app/database/generate_data_basic.py
new file mode 100644
index 0000000..7253dc9
--- /dev/null
+++ b/app/database/generate_data_basic.py
@@ -0,0 +1,33 @@
+import random, string
+from tinydb import TinyDB
+from tinydb.storages import JSONStorage
+from tinydb.middlewares import CachingMiddleware
+
+def randomstring(length):
+   letters = string.ascii_lowercase
+   return ''.join(random.choice(letters) for i in range(length))
+
+def generate_data(base_id, num_users):
+    data = []
+    for i in range(num_users):
+        data.append({
+        "user_id": str(base_id + i),
+        "name": randomstring(10),
+        "followers": random.randint(1, 10000),
+        "bio": randomstring(250),
+        "posts": randomstring(100),
+        "friends": random.choices(range(base_id + i - 1), k=random.randint(1, 50))
+    })
+
+    return data
+
+base_id = input("Enter base id (check db to find the next consecutive user_id): ")
+num_users = input("Enter number of users to generate: ")
+data = generate_data(int(base_id), int(num_users))
+
+# Create json file
+file_path = "datastore/llmData_sns.json"
+global db
+db = TinyDB(file_path, storage=CachingMiddleware(JSONStorage), indent=4)
+db.insert_multiple(data)
+db.close()
\ No newline at end of file