forked from anivenk25/Blood_reaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
47 lines (41 loc) · 1.55 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import firebase_admin
from firebase_admin import credentials, firestore
import random
from faker import Faker
# Initialize Firebase
cred = credentials.Certificate("/home/anirudh/Blood_reaper/blood-reaper-f7580-firebase-adminsdk-dwyff-21dae7f7ea.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
# Initialize Faker for generating fake data
fake = Faker()
# Function to generate random GeoPoint coordinates near Kolkata
def random_location():
base_lat = 22.5726
base_lon = 88.3639
lat_variation = random.uniform(-0.1, 0.1)
lon_variation = random.uniform(-0.1, 0.1)
return firestore.GeoPoint(base_lat + lat_variation, base_lon + lon_variation)
# Function to generate a random lab entry
def generate_lab_entry():
return {
"name": fake.company(),
"email": fake.email(),
"phone": fake.phone_number(),
"location": random_location(),
"blood_inventory": {
"AB+": str(random.randint(0, 100)),
"AB-": str(random.randint(0, 100)),
"A+": str(random.randint(0, 100)),
"A-": str(random.randint(0, 100)),
"B+": str(random.randint(0, 100)),
"B-": str(random.randint(0, 100)),
"O+": str(random.randint(0, 100)),
"O-": str(random.randint(0, 100))
}
}
# Generate and add multiple lab entries
num_entries = 10 # Number of lab entries to generate
for _ in range(num_entries):
lab_entry = generate_lab_entry()
db.collection("labs").add(lab_entry)
print(f"Added {num_entries} lab entries to Firestore.")