Skip to content

Commit 7df4c51

Browse files
author
Stephen Poserina
committed
create is_organization flag for potential organizations
1 parent da65700 commit 7df4c51

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/server/alembic/versions/fd187937528b_create_pdp_contacts_table.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@
1919

2020
def upgrade():
2121

22-
op.create_table('pdp_contact_types',
23-
sa.Column('contact_type_id', sa.String, primary_key=True)
24-
)
25-
26-
op.execute("""insert into pdp_contact_types values ('HOUSEHOLD'), ('ORGANIZATION');""")
27-
2822
op.create_table('pdp_contacts',
2923
sa.Column('_id', sa.Integer, primary_key=True, autoincrement=True),
3024
sa.Column('matching_id', sa.Integer, primary_key=True),
3125
sa.Column('source_type', sa.String, nullable=False),
3226
sa.Column('source_id', sa.String, nullable=False),
33-
sa.Column('contact_type_id', sa.String, sa.ForeignKey("pdp_contact_types.contact_type_id")),
27+
sa.Column('is_organization', sa.Boolean),
3428
sa.Column('first_name', sa.String),
3529
sa.Column('last_name', sa.String),
3630
sa.Column('email', sa.String),

src/server/pipeline/match_data.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,13 @@ 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-
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"])
109107

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

0 commit comments

Comments
 (0)