@@ -97,15 +97,13 @@ def start(connection, added_or_updated_rows, manual_matches_df, job_id):
97
97
connection .execute (query , matching_id = matching_id , old_id = old_id )
98
98
current_app .logger .info ("glue record found, changing id {} to {}" .format (old_id , matching_id ))
99
99
100
- contact_type_id = None
101
- if ("account_name" in row .keys ()):
102
- if (row ["account_name" ].lower ().endswith ("household" )):
103
- contact_type_id = "HOUSEHOLD"
104
- else :
105
- contact_type_id = "ORGANIZATION"
106
- insert = text ("insert into pdp_contacts(matching_id, source_type, source_id, contact_type_id, first_name, last_name, email, mobile, street_and_number, apartment, city, state, zip) \
107
- values(:matching_id, :source_type, :source_id, :contact_type_id, :first_name, :last_name, :email, :mobile, :street_and_number, :apartment, :city, :state, :zip)" )
108
- connection .execute (insert , matching_id = matching_id , source_type = row ["source_type" ], source_id = row ["source_id" ], contact_type_id = contact_type_id , first_name = row ["first_name" ], last_name = row ["last_name" ], email = row ["email" ], mobile = row ["mobile" ], street_and_number = row ["street_and_number" ], apartment = row ["apartment" ], city = row ["city" ], state = row ["state" ], zip = row ["zip" ])
100
+ is_organization = False
101
+ if "account_name" in row .keys ():
102
+ if row ["account_name" ] != None and not row ["account_name" ].lower ().endswith ("household" ):
103
+ is_organization = True
104
+ insert = text ("insert into pdp_contacts(matching_id, source_type, source_id, is_organization, first_name, last_name, email, mobile, street_and_number, apartment, city, state, zip) \
105
+ values(:matching_id, :source_type, :source_id, :is_organization, :first_name, :last_name, :email, :mobile, :street_and_number, :apartment, :city, :state, :zip)" )
106
+ connection .execute (insert , matching_id = matching_id , source_type = row ["source_type" ], source_id = row ["source_id" ], is_organization = is_organization , first_name = row ["first_name" ], last_name = row ["last_name" ], email = row ["email" ], mobile = row ["mobile" ], street_and_number = row ["street_and_number" ], apartment = row ["apartment" ], city = row ["city" ], state = row ["state" ], zip = row ["zip" ])
109
107
110
108
current_app .logger .info ("- Finished load to pdp_contacts table" )
111
109
log_db .log_exec_status (job_id , 'matching' , 'executing' , str ({'at_row' : len (rows ), 'of_rows' : len (rows ) }) )
0 commit comments