forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_phone_call_source.py
More file actions
50 lines (35 loc) · 1.68 KB
/
Copy pathpatch_phone_call_source.py
File metadata and controls
50 lines (35 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""One-time Firestore patch: change source='phone_call' to source='phone'.
Usage:
python scripts/patch_phone_call_source.py --uid <UID> [--dry-run]
Scans all conversations for the specified user and patches source field.
"""
import argparse
from typing import Any, List
import firebase_admin
from firebase_admin import firestore
def main() -> None:
parser = argparse.ArgumentParser(description='Patch phone_call source to phone in Firestore')
parser.add_argument('--uid', required=True, help='User UID to patch')
parser.add_argument('--dry-run', action='store_true', help='Print affected doc IDs without modifying')
args = parser.parse_args()
if not firebase_admin._apps: # type: ignore[reportPrivateUsage] # firebase_admin internals
firebase_admin.initialize_app() # type: ignore[reportUnknownMemberType] # firebase_admin untyped
db: Any = firestore.client() # type: ignore[reportUnknownMemberType] # firebase_admin untyped
conversations_ref: Any = db.collection('users').document(args.uid).collection('conversations')
query: Any = conversations_ref.where('source', '==', 'phone_call')
docs: List[Any] = list(query.stream())
print(f'Found {len(docs)} conversations with source=phone_call')
if not docs:
print('Nothing to patch.')
return
for doc in docs:
print(f' doc_id={doc.id}')
if not args.dry_run:
doc.reference.update({'source': 'phone'})
print(f' -> patched to source=phone')
if args.dry_run:
print('\nDry run — no changes made. Remove --dry-run to apply.')
else:
print(f'\nPatched {len(docs)} documents.')
if __name__ == '__main__':
main()