Skip to content

Commit

Permalink
Merge pull request #27 from bcgov/feature/fixgeoorecon
Browse files Browse the repository at this point in the history
updated geo events retry
  • Loading branch information
amlanc1 authored Nov 9, 2023
2 parents b39fe22 + 14d00dd commit fd5b977
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
28 changes: 19 additions & 9 deletions src/commonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,25 @@ def map_source_db(source):

def split_etk_event_payloads(payload,eventtype):
payload_dict=json.loads(payload)
eventpayload=payload_dict.pop('event')
countspayload=None
geopayload=None
if eventtype=='etk_issuance':
countspayload=payload_dict.pop('counts')
geopayload={}
geopayload['business_id']=payload_dict['ticket_number']
geopayload=json.dumps(geopayload)
return json.dumps(payload_dict),json.dumps(eventpayload),countspayload,geopayload
eventpayload = None
countspayload = None
geopayload = None
if eventtype=='geolocation':
tmp_event=payload_dict.pop('event')
main_event={}
main_event['business_id']=payload_dict['ticket_number']
payload_dict=main_event
else:
eventpayload=payload_dict.pop('event')
countspayload=None
geopayload=None
if eventtype=='etk_issuance':
countspayload=payload_dict.pop('counts')
geopayload={}
geopayload['business_id']=payload_dict['ticket_number']
geopayload=json.dumps(geopayload)
eventpayload=json.dumps(eventpayload)
return json.dumps(payload_dict),eventpayload,countspayload,geopayload

# def map_source_api_keys(source):
# if source=='df':
Expand Down
5 changes: 5 additions & 0 deletions src/errorretryfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def error_retry_task(dbclient,err_staging_collection,err_table_collection,err_th
if row['eventType'] :
# DONE: Retry sending to producer api
payload_json=row['payloaddata']
if row['eventType']=='geolocation':
payload_arr=[]
payload_arr.append(json.loads(payload_json))
payload_json=payload_arr
payload_json=json.dumps(payload_json)
producer_api_obj=producerAPITasks(os.getenv('PRODUCER_API_HOST'),logger)
headers={'ride-api-key':os.getenv('RIDE_API_KEY'),'Content-Type':'application/json'}
logger.debug(payload_json)
Expand Down
3 changes: 2 additions & 1 deletion src/reconfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def recondestination(dbclient,main_staging_collection,main_table_collection,logg
mainfound, eventfound, countsfound,geofound = False, False, False,False
if mainpayload:
mainqrystr = bi_sql_db_obj.prepQuerystr(mainpayload,row['datasource'])
table_name = bi_table_name
table_name=(lambda x: bi_geo_table if x['eventType']=='geolocation' else bi_table_name)(row)
# table_name = bi_table_name
reconqrystr = f'SELECT * FROM {table_name} WHERE {mainqrystr}'
mainfound = bi_sql_db_obj.reconQuery(reconqrystr,logger)
if eventpayload:
Expand Down

0 comments on commit fd5b977

Please sign in to comment.