Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cben to modernized types #267

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions search-solr-importer/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
2 changes: 2 additions & 0 deletions search-solr-importer/src/search_solr_importer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Config(): # pylint: disable=too-few-public-methods
REINDEX_CORE = os.getenv('REINDEX_CORE', 'False') == 'True'
PRELOADER_JOB = os.getenv('PRELOADER_JOB', 'False') == 'True'

MODERNIZED_LEGAL_TYPES = os.getenv('MODERNIZED_LEGAL_TYPES', 'BEN,CBEN,CP,GP,SP').upper().split(',')

# ORACLE - CDEV/CTST/CPRD
ORACLE_USER = os.getenv('ORACLE_USER', '')
ORACLE_PASSWORD = os.getenv('ORACLE_PASSWORD', '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@
from search_solr_importer import oracle_db


def _get_stringified_list_for_sql(config_value: str) -> str:
"""Return the values from the config in a format usable for the execute statement."""
if items := current_app.config.get(config_value, []):
return ','.join([f"'{x}'" for x in items]).replace(')', '')

return ''


def collect_colin_data():
"""Collect data from COLIN."""
current_app.logger.debug('Connecting to Oracle instance...')
cursor = oracle_db.connection.cursor()
current_app.logger.debug('Collecting COLIN data...')
cursor.execute("""
cursor.execute(f"""
SELECT c.corp_num as identifier, c.corp_typ_cd as legal_type, c.bn_15 as tax_id,
c.last_ar_filed_dt as last_ar_date, c.recognition_dts as founding_date, c.transition_dt,
cn.corp_nme as legal_name, cp.business_nme as organization_name, cp.first_nme as first_name,
Expand All @@ -46,7 +54,7 @@ def collect_colin_data():
from corp_party
where end_event_id is null and party_typ_cd in ('FIO','FBO')
) cp on cp.corp_num = c.corp_num
WHERE c.corp_typ_cd not in ('BEN','CP','GP','SP')
WHERE c.corp_typ_cd not in ({_get_stringified_list_for_sql('MODERNIZED_LEGAL_TYPES')})
and cs.end_event_id is null
and cn.end_event_id is null
and cn.corp_name_typ_cd in ('CO', 'NB')
Expand All @@ -67,7 +75,7 @@ def collect_lear_data():
password=current_app.config.get('DB_PASSWORD'))
cur = conn.cursor()
current_app.logger.debug('Collecting LEAR data...')
cur.execute("""
cur.execute(f"""
SELECT b.identifier,b.legal_name,b.legal_type,b.tax_id,b.last_ar_date,
b.founding_date,b.restoration_expiry_date,pr.role,
p.first_name,p.middle_initial,p.last_name,p.organization_name,p.party_type,p.id as party_id,
Expand All @@ -76,7 +84,7 @@ def collect_lear_data():
LEFT JOIN (SELECT * FROM party_roles WHERE cessation_date is null
AND role in ('partner', 'proprietor')) as pr on pr.business_id = b.id
LEFT JOIN parties p on p.id = pr.party_id
WHERE b.legal_type in ('BEN', 'CP', 'SP', 'GP')
WHERE b.legal_type in ({_get_stringified_list_for_sql('MODERNIZED_LEGAL_TYPES')})
""")
return cur

Expand All @@ -91,7 +99,7 @@ def _collect_lear_data_gcp():
password=current_app.config.get('DB_PASSWORD'))
cur = conn.cursor()
current_app.logger.debug('Collecting LEAR data...')
cur.execute("""
cur.execute(f"""
SELECT le.identifier,le.legal_name,le.entity_type as legal_type,le.founding_date,
le.restoration_expiry_date,le.last_ar_date,alt.name as legal_name_alt,
er.role_type as role,er.appointment_date,
Expand Down Expand Up @@ -122,7 +130,7 @@ def _collect_lear_data_gcp():
AND rle_alt.name_type = 'OPERATING'
AND rle_alt.end_date IS NULL
LEFT JOIN colin_entities rle_colin ON rle_colin.id = er.related_colin_entity_id
WHERE le.entity_type in ('BEN', 'CP', 'SP', 'GP')
WHERE le.entity_type in ({_get_stringified_list_for_sql('MODERNIZED_LEGAL_TYPES')})
AND er.cessation_date IS NULL
""")
return cur
2 changes: 1 addition & 1 deletion search-solr-importer/src/search_solr_importer/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.3.1' # pylint: disable=invalid-name
__version__ = '1.3.2' # pylint: disable=invalid-name
Loading