Skip to content

Commit

Permalink
Generated 1500 test data
Browse files Browse the repository at this point in the history
  • Loading branch information
arikamat committed Apr 1, 2023
1 parent 2089c4c commit bb2abd5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ firebase.js
.env
# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

/firebase
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "yapf"
}
18 changes: 18 additions & 0 deletions data_generator/counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import names
from random import randint
import firebase_admin
from firebase_admin import firestore
from firebase_admin import credentials

cred = credentials.Certificate("../firebase/homestay.json")
firebase_admin.initialize_app(cred)

db = firestore.client()
doc_ref = db.collection('users')
docs = doc_ref.get()
count = 0

for doc in docs:
count += 1

print(count)
36 changes: 36 additions & 0 deletions data_generator/data_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import names
from random import randint
import firebase_admin
from firebase_admin import firestore
from firebase_admin import credentials

cred = credentials.Certificate("../firebase/homestay.json")
firebase_admin.initialize_app(cred)

db = firestore.client()

for i in range(66):

f_name = names.get_first_name()
age = randint(18, 85)
activity = ["Sightseeing", "Adventure", "Relaxation", "Culture"]
house = ["Apartment", "Cabin", "House"]
family = [
"Single", "Couple", "Family with children", "Family with no children",
"Group of friends"
]

a = activity[randint(0, len(activity)-1)]
h = house[randint(0, len(house)-1)]
f = family[randint(0, len(family)-1)]
data = {
'name': f_name,
'age' : age,
'preferences':{
'activityType': a,
'familyType':f,
'housestayType':h
}
}
db.collection('users').add(data)
print(i)
2 changes: 1 addition & 1 deletion screens/Demographic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Alert,
} from "react-native";
import { db } from "../firebase";
const usersRef = db.collection('users');
const usersRef = db.collection("users");
export default function Demographic() {
const [age, setAge] = useState("");
const [housestayType, setHousestayType] = useState("");
Expand Down

0 comments on commit bb2abd5

Please sign in to comment.