open inculbation
This commit is contained in:
25
scripts/open_incubation.py
Normal file
25
scripts/open_incubation.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import firebase_admin
|
||||
from firebase_admin import credentials, firestore
|
||||
import os
|
||||
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||
|
||||
key_path = os.getcwd() + '/keys/hpos-af3cc-firebase-adminsdk.json'
|
||||
cred = credentials.Certificate(key_path)
|
||||
firebase_admin.initialize_app(cred)
|
||||
def update_incubation(source_collection):
|
||||
db = firestore.client()
|
||||
|
||||
docs = db.collection(source_collection).where(filter = FieldFilter("_id", "==", "207296063672UTKLSP3")).stream()
|
||||
|
||||
for doc in docs:
|
||||
doc_id = doc.id #doc.to_dict()["_id"]
|
||||
print(doc_id)
|
||||
|
||||
try:
|
||||
db.collection(source_collection).document(doc_id).update({"testStatus": False, "incubationTime": "2023-10-12 9:29:00"})
|
||||
print(f"Document with ID '{doc_id}' updated")
|
||||
except Exception as e:
|
||||
print(f"Error updating document with ID '{doc_id}' from the source collection: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_incubation("patientData")
|
||||
@@ -1,21 +0,0 @@
|
||||
import firebase_admin
|
||||
from firebase_admin import credentials, firestore
|
||||
import os
|
||||
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||
|
||||
key_path = os.getcwd() + '/scripts/keys/hpos-preprod-firebase-adminsdk-d6jjt-ae42ad0f67.json'
|
||||
cred = credentials.Certificate(key_path)
|
||||
firebase_admin.initialize_app(cred)
|
||||
def update_incubation(source_collection):
|
||||
db = firestore.client()
|
||||
|
||||
doc_id = "2783399292GMC"
|
||||
|
||||
try:
|
||||
db.collection(source_collection).document(doc_id).update({"incubationTime": "2023-10-09 12:53:00"})
|
||||
print(f"Document with ID '{doc_id}' updated")
|
||||
except Exception as e:
|
||||
print(f"Error deleting document with ID '{doc_id}' from the source collection: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_incubation("patientData")
|
||||
Reference in New Issue
Block a user