change user search partition
This commit is contained in:
40
scripts/change_search_partition.py
Normal file
40
scripts/change_search_partition.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import os
|
||||||
|
import firebase_admin
|
||||||
|
from firebase_admin import credentials
|
||||||
|
from firebase_admin import firestore
|
||||||
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||||
|
import pandas as pd
|
||||||
|
#import datetime
|
||||||
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
# Initialize Firebase Admin SDK
|
||||||
|
cred = credentials.Certificate(os.getcwd() + '/keys/hpos-prod-firebase-adminsdk.json') # Replace with your own service account key path
|
||||||
|
firebase_admin.initialize_app(cred)
|
||||||
|
|
||||||
|
# Get a reference to the Firestore database
|
||||||
|
db = firestore.client()
|
||||||
|
|
||||||
|
# Specify the collections
|
||||||
|
patient_collection = db.collection("patientData")
|
||||||
|
test_collection = db.collection("testData")
|
||||||
|
# start_date = sys.argv[1] # '2023-01-12' #input("Please enter the start date (yyyy-mm-dd): ")
|
||||||
|
# end_date = sys.argv[2] #'2023-07-16' #input("Please enter the end date (yyyy-mm-dd): ")
|
||||||
|
|
||||||
|
query = patient_collection.where(filter=FieldFilter("createdAt", ">=", "2023-10-17")).where(filter=FieldFilter("createdAt", "<", "2023-10-18"))
|
||||||
|
#.where(filter=FieldFilter("registrationCenterName", "==", "SCS high school"))
|
||||||
|
patient_docs = query.stream()
|
||||||
|
|
||||||
|
# Prepare data to store in CSV
|
||||||
|
data = []
|
||||||
|
for patient_doc in patient_docs:
|
||||||
|
patient_data = patient_doc.to_dict()
|
||||||
|
data.append(patient_data)
|
||||||
|
# print(patient_data['_idSearch'])
|
||||||
|
# if patient_data['_idSearch'] is None:
|
||||||
|
# # print(patient_doc.id)
|
||||||
|
# print(patient_data['_id'])
|
||||||
|
print(patient_data['_id'])
|
||||||
|
db.collection("patientData").document(patient_doc.id).update({"_idSearch": '20231028' + patient_data['_id']})
|
||||||
|
|
||||||
Reference in New Issue
Block a user