Skip to content

Commit da65700

Browse files
author
Stephen Poserina
committed
add check to determine if account is individual or organization
1 parent 2ed2d87 commit da65700

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/server/alembic/versions/fd187937528b_create_pdp_contacts_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def upgrade():
2323
sa.Column('contact_type_id', sa.String, primary_key=True)
2424
)
2525

26-
op.execute("""insert into pdp_contact_types values ('PERSON'), ('ORGANIZATION');""")
26+
op.execute("""insert into pdp_contact_types values ('HOUSEHOLD'), ('ORGANIZATION');""")
2727

2828
op.create_table('pdp_contacts',
2929
sa.Column('_id', sa.Integer, primary_key=True, autoincrement=True),

src/server/datasource_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __clean_csv_headers(header):
1212
'Apartment', 'City', 'State', 'Zip', 'Email', 'Phone', 'Animal_ids'],
1313
'volgistics': ['Last name', 'First name', 'Middle name', 'Number', 'Complete address', 'Street 1', 'Street 2',
1414
'Street 3', 'City', 'State', 'Zip', 'All phone numbers', 'Home', 'Work', 'Cell', 'Email'],
15-
'salesforcecontacts': ['Contact ID 18', 'First Name', 'Last Name', 'Mailing Street', 'Mailing City',
15+
'salesforcecontacts': ['Account Name', 'Contact ID 18', 'First Name', 'Last Name', 'Mailing Street', 'Mailing City',
1616
'Mailing State/Province', 'Mailing Zip/Postal Code', 'Mailing Country', 'Phone', 'Mobile',
1717
'Email', 'Account ID 18', 'Volgistics ID', 'Person ID'],
1818
'volgisticsshifts': ['Number', 'Place', 'Assignment', 'From date', 'To date', 'Hours'],
@@ -115,6 +115,7 @@ def normalize_phone_number(number):
115115
"city": "mailing_city",
116116
"state": "mailing_state_province",
117117
"zip": "mailing_zip_postal_code",
118+
"account_name": "account_name",
118119
"others": {
119120
"should_drop_first_column": True
120121
}

src/server/pipeline/match_data.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ def start(connection, added_or_updated_rows, manual_matches_df, job_id):
9797
connection.execute(query, matching_id=matching_id, old_id=old_id)
9898
current_app.logger.info("glue record found, changing id {} to {}".format(old_id, matching_id))
9999

100-
insert = text("insert into pdp_contacts(matching_id, source_type, source_id, first_name, last_name, email, mobile, street_and_number, apartment, city, state, zip) \
101-
values(:matching_id, :source_type, :source_id, :first_name, :last_name, :email, :mobile, :street_and_number, :apartment, :city, :state, :zip)")
102-
connection.execute(insert, matching_id=matching_id, source_type=row["source_type"], source_id=row["source_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+
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"])
103109

104110
current_app.logger.info("- Finished load to pdp_contacts table")
105111
log_db.log_exec_status(job_id, 'matching', 'executing', str({'at_row': len(rows), 'of_rows': len(rows) }) )

0 commit comments

Comments
 (0)