29 lines
898 B
Python
29 lines
898 B
Python
|
|
import os
|
||
|
|
import firebase_admin
|
||
|
|
from firebase_admin import credentials
|
||
|
|
from firebase_admin import firestore
|
||
|
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
||
|
|
|
||
|
|
cred = credentials.Certificate(os.getcwd() + '/keys/hpos-qa-firebase-adminsdk.json')
|
||
|
|
firebase_admin.initialize_app(cred)
|
||
|
|
|
||
|
|
db = firestore.client()
|
||
|
|
|
||
|
|
test_collection = db.collection("testData")
|
||
|
|
|
||
|
|
# Query tests based on the "testTime" field
|
||
|
|
query = test_collection.where("testTime", ">=", "2024-01-23")
|
||
|
|
test_docs = query.stream()
|
||
|
|
batch = db.batch()
|
||
|
|
|
||
|
|
for test_doc in test_docs:
|
||
|
|
test_data = test_doc.to_dict()
|
||
|
|
result_data_words = test_data.get("resultData", "").split()
|
||
|
|
# print(result_data_words)
|
||
|
|
|
||
|
|
if len(result_data_words) >= 2:
|
||
|
|
second_word = result_data_words[1]
|
||
|
|
test_ref = db.collection("testData").document(test_doc.id)
|
||
|
|
batch.update(test_ref, {"deviceId": second_word})
|
||
|
|
|
||
|
|
batch.commit()
|