I used python script to fetch heart rates from smartwatch and save it to firebase database using the following lines:
for element in dataPoints: data_ref = db.collection("patients").document("patient0").collection("physioData").document(element["sensor"]).collection("data").document("data" + str(element["index"])) add_data = {"value": element["value"], "sensor": element["sensor"], "valueFullDate": element["valueFullDate"]} data_ref.set(add_data)
The problem is that it fetches all data point every time I run it even the old ones and save it all to firebase which takes huge time (40 min to save 42,000 data points = 12 hours monitoring).But what I want is to fetch new data point only to save time and save the new only to firebase.
One way I thought about it is to run the script daily through a scheduler or run it on the cloud, but is there a better approach?