from google.cloud import firestore
import argparse
import datetime
import names
import random

genders = [u'male', u'female']
interests = [u'Movies', u'Football', u'Books', u'Music']

def queryUsers(db):
	users_ref = db.collection(u'users')
	docs = users_ref.get()

	for doc in docs:
	  print(u'{} => {}'.format(doc.id, doc.to_dict()))


def addUser(db, ref_lat, ref_lon, range):
	doc_ref = db.collection(u'users').document()
	uid = doc_ref.id
	gender = random.choice(genders)
	lat = ref_lat + random.uniform(-range, range)
	lon = ref_lon + random.uniform(-range, range)
	doc_ref.set({
    u'desc': u'Test user created using a script',
    u'id': uid,
    u'name': names.get_full_name(gender=gender),
    u'linkUrl': u'https://www.google.com',
    u'email': u'fake@gmail.com',
    u'urofilePicUrl': None,
    u'age': random.randint(14,80),
    u'timestamp': datetime.datetime.now(),
    u'interests': [random.choice(interests)],
	  u'location': [lat, lon]
	})
	doc = doc_ref.get()
	print(u'Created {} => {}'.format(doc.id, doc.to_dict()))



if __name__ == '__main__':
	parser = argparse.ArgumentParser()
	parser.add_argument("-c", "--count", type=int, default=3)
	parser.add_argument("--lat", type=float, default=37.0)
	parser.add_argument("--lon", type=float, default=-122.0)
	parser.add_argument("--range", type=float, default=-0.000001)
	args = parser.parse_args()
	db = firestore.Client()


	for i in range(0, args.count):
		addUser(db, args.lat, args.lon, args.range)

	# Uncomment to query all users
	# queryUsers(db)

@@ -175,16 +175,33 @@
 'Music'%5D
+%0Ascript_version=1
 %0A%0Adef qu
@@ -793,17 +793,17 @@
 ,%0A    u'
-u
+p
 rofilePi
@@ -815,16 +815,39 @@
 : None,%0A
+    u'gender': gender,%0A
     u'ag
@@ -988,16 +988,82 @@
 at, lon%5D
+,%0A%09  u'createdByScript': True,%0A%09  u'scriptVersion': script_version
 %0A%09%7D)%0A%09do

Fix to add user script + add versioning