Updating things for LCI
This commit is contained in:
@@ -207,10 +207,10 @@ obj_type_kv_li['event_file'] = {'table_name': 'v_event_file_simple', 'tbl_name_u
|
||||
obj_type_kv_li['event_location'] = {'table_name': 'v_event_location', 'tbl_name_update': 'event_location', 'base_name': Event_Location_Base}
|
||||
obj_type_kv_li['event_person'] = {'table_name': 'v_event_person', 'tbl_name_update': 'event_person', 'base_name': Event_Person_Base}
|
||||
obj_type_kv_li['event_person_tracking'] = {'table_name': 'v_event_person_tracking', 'tbl_name_update': 'event_person_tracking', 'base_name': Event_Person_Tracking_Base}
|
||||
obj_type_kv_li['event_presentation'] = {'table_name': 'v_event_presentation', 'tbl_name_update': 'event_presentation', 'base_name': Event_Presentation_Base}
|
||||
# obj_type_kv_li['event_presenter'] = {'table_name': 'v_event_presenter', 'tbl_name_update': 'event_presenter', 'base_name': Event_Presenter_Base}
|
||||
obj_type_kv_li['event_presentation'] = {'table_name': 'v_event_presentation', 'table_name_alt': 'v_event_presentation_w_file_count', 'tbl_name_update': 'event_presentation', 'base_name': Event_Presentation_Base}
|
||||
obj_type_kv_li['event_presenter'] = {'table_name': 'v_event_presenter', 'table_name_alt': 'v_event_presenter_w_file_count', 'tbl_name_update': 'event_presenter', 'base_name': Event_Presenter_Base}
|
||||
obj_type_kv_li['event_registration'] = {'table_name': 'v_event_registration', 'tbl_name_update': 'event_registration', 'base_name': Event_Registration_Base}
|
||||
obj_type_kv_li['event_session'] = {'table_name': 'v_event_session', 'tbl_name_update': 'event_session', 'base_name': Event_Session_Base, 'exclude_for_db': {'poc_person_id', 'file_count', 'internal_use_count', 'enable_from', 'enable_to', 'event_name', 'event_start_datetime', 'event_end_datetime', 'event_location_name', 'event_track_name', 'event_abstract_list', 'event_badge_list', 'event_device_list', 'event_file_list', 'event_file_internal_use_list', 'event_location', 'event_location_list', 'event_person_list', 'event_presenter_cat', 'event_presentation_list', 'event_presenter_list', 'event_track', 'poc_event_person'}}
|
||||
obj_type_kv_li['event_session'] = {'table_name': 'v_event_session', 'table_name_alt': 'v_event_session_w_file_count', 'tbl_name_update': 'event_session', 'base_name': Event_Session_Base, 'exclude_for_db': {'poc_person_id', 'file_count', 'internal_use_count', 'enable_from', 'enable_to', 'event_name', 'event_start_datetime', 'event_end_datetime', 'event_location_name', 'event_track_name', 'event_abstract_list', 'event_badge_list', 'event_device_list', 'event_file_list', 'event_file_internal_use_list', 'event_location', 'event_location_list', 'event_person_list', 'event_presenter_cat', 'event_presentation_list', 'event_presenter_list', 'event_track', 'poc_event_person'}}
|
||||
obj_type_kv_li['event_track'] = {'table_name': 'v_event_track', 'tbl_name_update': 'event_track', 'base_name': Event_Track_Base}
|
||||
|
||||
obj_type_kv_li['grant'] = {'table_name': 'v_grant', 'tbl_name_update': 'grant', 'base_name': Grant_Base}
|
||||
|
||||
@@ -719,6 +719,11 @@ async def event_importing_program_data(
|
||||
event_presentation_data['end_datetime'] = None
|
||||
data['presentation_end_datetime'] = None
|
||||
|
||||
if record.get('abstract_code'):
|
||||
event_presentation_data['abstract_code'] = record.get('abstract_code')
|
||||
else:
|
||||
event_presentation_data['abstract_code'] = None
|
||||
|
||||
event_presentation_data['sort'] = record.get('presentation_sort')
|
||||
|
||||
event_presentation_data['enable'] = True
|
||||
@@ -765,17 +770,28 @@ async def event_importing_program_data(
|
||||
|
||||
# NEW - Way to handle a semicolon delimited list of presenters in a single cell
|
||||
if presenter_full_name_li := record.get('presenter_full_name_li', None):
|
||||
log.info(f'Found {presenter_full_name_li}')
|
||||
presenter_full_name_li = presenter_full_name_li.split(';')
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(f'Found presenter list {presenter_full_name_li}')
|
||||
# Split the list and trim whitespace
|
||||
presenter_full_name_li = [x.strip() for x in presenter_full_name_li.split(';')] # Split on semicolon
|
||||
event_presenter_li = []
|
||||
for presenter_full_name in presenter_full_name_li:
|
||||
event_presenter_record_results = process_event_presenter_w_full_name(
|
||||
account_id = account_id,
|
||||
event_id = event_id,
|
||||
event_session_id = event_session_id,
|
||||
event_presentation_id = event_presentation_id, presenter_full_name=presenter_full_name
|
||||
)
|
||||
presentation_summary_data = event_presenter_record_results
|
||||
event_presenter_li.append(presentation_summary_data)
|
||||
|
||||
data['event_presenter_li'] = event_presenter_li
|
||||
# data['event_presenter_full_name_li'] = presenter_full_name_li
|
||||
|
||||
# End of the loop. Append to program list data results.
|
||||
|
||||
event_program_data_li.append(data)
|
||||
log.info(f'Record processed: Session: {event_session_id} Presentation: {event_presentation_id} Presenter list: {presenter_full_name_li}')
|
||||
|
||||
else:
|
||||
# OLD - Way to handle a single presenter per row
|
||||
@@ -1092,16 +1108,29 @@ def process_person_data(account_id, source_code, record):
|
||||
|
||||
# This will try to look up the person record based on their full name and then update the event presenter record. If the person record is not found, it will return False. If the person record is found, it will return the person record data.
|
||||
# Should we also pass event_id and event_session_id?
|
||||
def process_event_presenter_w_full_name(event_presentation_id, presenter_full_name):
|
||||
def process_event_presenter_w_full_name(account_id, event_id, event_session_id, event_presentation_id, presenter_full_name):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# First - SQL SELECT to find the person record based on the full name
|
||||
# If the person record is found, use the person_id to UPDATE the event_presenter record. In the future this will likely be a new table named person_profile. It will likely be a combination of the person, event_badge, and event_presenter tables.
|
||||
if person_rec := sql_select(table_name='v_person', field_name='full_name', field_value=presenter_full_name):
|
||||
# if person_rec := sql_select(table_name='v_person', field_name='full_name', field_value=presenter_full_name):
|
||||
qry_data = {
|
||||
'account_id': account_id,
|
||||
'full_name': presenter_full_name,
|
||||
}
|
||||
if person_rec := sql_select(table_name='v_person', data=qry_data, log_lvl=logging.INFO):
|
||||
if not isinstance(person_rec, list):
|
||||
person_id = person_rec.get('person_id', None)
|
||||
person_id_random = person_rec.get('person_id_random', None)
|
||||
log.info(f'Found one record. Person ID: {person_id_random} Person Full Name: {presenter_full_name}')
|
||||
log.debug(person_rec)
|
||||
|
||||
summary_data = {}
|
||||
summary_data['full_name'] = person_rec.get('full_name', None)
|
||||
summary_data['email'] = person_rec.get('primary_email', None)
|
||||
|
||||
# return summary_data
|
||||
else:
|
||||
log.warning('Found more than one record')
|
||||
log.warning(person_rec)
|
||||
@@ -1113,7 +1142,12 @@ def process_event_presenter_w_full_name(event_presentation_id, presenter_full_na
|
||||
|
||||
# Second - SQL SELECT to find the event presenter record based on the event_presentation_id and the person_id returned from the first SQL SELECT
|
||||
# If the event presenter record is found, UPDATE the record with the person_id
|
||||
if event_presenter_rec := sql_select(table_name='v_event_presenter', field_name='event_presentation_id', field_value=event_presentation_id):
|
||||
# if event_presenter_rec := sql_select(table_name='v_event_presenter', field_name='event_presentation_id', field_value=event_presentation_id):
|
||||
qry_data = {
|
||||
'event_presentation_id': event_presentation_id,
|
||||
'person_id': person_id,
|
||||
}
|
||||
if event_presenter_rec := sql_select(table_name='v_event_presenter', data=qry_data, log_lvl=logging.INFO):
|
||||
if not isinstance(event_presenter_rec, list):
|
||||
event_presenter_id = event_presenter_rec.get('event_presenter_id', None)
|
||||
event_presenter_id_random = event_presenter_rec.get('event_presenter_id_random', None)
|
||||
@@ -1123,10 +1157,12 @@ def process_event_presenter_w_full_name(event_presentation_id, presenter_full_na
|
||||
return False
|
||||
|
||||
data = {}
|
||||
data['id'] = event_presenter_id
|
||||
data['person_id'] = person_id
|
||||
data['full_name'] = person_rec['full_name']
|
||||
data['email'] = person_rec['primary_email']
|
||||
|
||||
if event_presenter_obj_up_result := sql_update(data=data, table_name='event_presenter'):
|
||||
summary_data['event_presenter_id'] = event_presenter_id
|
||||
|
||||
if event_presenter_obj_up_result := sql_update(data=data, table_name='event_presenter', record_id=event_presenter_id):
|
||||
log.debug(event_presenter_obj_up_result)
|
||||
else:
|
||||
log.warning(event_presenter_obj_up_result)
|
||||
@@ -1134,16 +1170,16 @@ def process_event_presenter_w_full_name(event_presentation_id, presenter_full_na
|
||||
# If the event presenter record is not found, INSERT a new record with the person_id
|
||||
else:
|
||||
data = {}
|
||||
data['event_id'] = event_id
|
||||
data['event_session_id'] = event_session_id
|
||||
data['event_presentation_id'] = event_presentation_id
|
||||
data['person_id'] = person_id
|
||||
# WARNING: person_id does not exist in the event_presenter table. This is a new field that will be added. It will make more sense to have a person_profile table that combines the person, event_badge, and event_presenter tables.
|
||||
data['person_id'] = person_id # WARNING!
|
||||
|
||||
# This should fill out the event_presenter record based on the person record. This will likely be a new table named person_profile. It will likely be a combination of the person, event_badge, and event_presenter tables.
|
||||
data['external_id'] = person_rec['external_id']
|
||||
# Do we know the presenter code (or number)?
|
||||
# Do we know for_type or for_id?
|
||||
# data['event_id'] = person_rec['event_id']
|
||||
# data['event_session_id'] = person_rec['event_session_id']
|
||||
# data['event_presentation_id'] = person_rec['event_presentation_id']
|
||||
|
||||
|
||||
data['informal_name'] = person_rec['informal_name']
|
||||
@@ -1159,13 +1195,12 @@ def process_event_presenter_w_full_name(event_presentation_id, presenter_full_na
|
||||
data['affiliations'] = person_rec['affiliations']
|
||||
data['email'] = person_rec['primary_email']
|
||||
|
||||
|
||||
if event_presenter_obj_in_result := sql_insert(data=data, table_name='event_presenter'):
|
||||
log.debug(event_presenter_obj_in_result)
|
||||
event_presenter_id = event_presenter_obj_in_result
|
||||
summary_data['event_presenter_id'] = event_presenter_id
|
||||
else:
|
||||
log.warning(event_presenter_obj_in_result)
|
||||
|
||||
|
||||
|
||||
return False
|
||||
return summary_data
|
||||
Reference in New Issue
Block a user