-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_test_data.py
executable file
·65 lines (55 loc) · 1.76 KB
/
insert_test_data.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from pymongo import MongoClient
import os
from dotenv import load_dotenv
import certifi
import re
load_dotenv()
# Use MongoDB Atlas with SSL certificate path
client = MongoClient(os.getenv('MONGODB_URI'), tlsCAFile=certifi.where())
db = client['pay_per_call_db']
def clean_phone_number(phone):
"""Clean phone number to standard format"""
# Remove any non-digit characters
digits_only = re.sub(r'\D', '', phone)
# Remove leading 1 if present (country code)
if len(digits_only) == 11 and digits_only.startswith('1'):
digits_only = digits_only[1:]
return digits_only
# Example survey data
survey_data = {
"Phone": clean_phone_number("+19097648539"),
"FName": "Chris",
"LName": "Smitley",
"LAmount": "250000",
"LType": "mortgage refinance",
"Credit": "720",
"tags": [] # Empty array - will be populated from the tags collection
}
# Insert test tags collection if it doesn't exist
test_tags = [
{"tag_name": "mortgage refinance", "category": "loans"},
{"tag_name": "debt consolidation", "category": "financial"},
{"tag_name": "home improvement", "category": "home"},
# Add more tags as needed
]
# Create tags collection
tags_collection = db["tags"]
for tag in test_tags:
tags_collection.update_one(
{"tag_name": tag["tag_name"]},
{"$set": tag},
upsert=True
)
# Insert into surveys collection
result = db.surveys.insert_one(survey_data)
# Insert test offer
test_offer = {
"offerName": "Test Refinance Company",
"minMortgageBalance": 100000,
"maxMortgageBalance": 500000,
"routeToPhoneNumber": "+13369390718", # Twilio number that receives calls
"conversionRate": 0.85
}
# Insert the documents
db.offers.insert_one(test_offer)
print("Test data inserted successfully!")