From 7b1284d2c4869168ef7304194b794bf1f6242f41 Mon Sep 17 00:00:00 2001 From: RamonaEJSpence Date: Tue, 12 May 2020 13:04:41 -0400 Subject: [PATCH 1/3] edit in config --- config.ini.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.ini.example b/config.ini.example index 8e3454a..9d14aed 100644 --- a/config.ini.example +++ b/config.ini.example @@ -9,4 +9,4 @@ username = user update_cal_location = /home/user/upstate_tech_cal_service/update_cal_data.py [past_events] -past_days = 5 \ No newline at end of file +days_in_the_past = 5 \ No newline at end of file From 726c0b26566f14ee1228304f6c4c9b263a38392e Mon Sep 17 00:00:00 2001 From: RamonaEJSpence Date: Tue, 12 May 2020 12:58:28 -0400 Subject: [PATCH 2/3] format_eventbrite_events includes online events --- app.py | 52 ++++++++++++++++++++++++++++++---------------- update_cal_data.py | 1 - 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/app.py b/app.py index 4606134..3e777ce 100644 --- a/app.py +++ b/app.py @@ -212,31 +212,48 @@ def format_eventbrite_events(events_list, venues_list, group_list): 'lon': venue_address.get('longitude') } venues[venue_id] = venue_dict + for event in events_list: - if type(event.get('venue_id')) == str: # If venue id error + if type(event.get('venue_id')) == str or event.get('venue_id') is None: # If venue id error group_item = [i for i in group_list if i['field_events_api_key'] == event.get('organizer_id')][0] group_name = group_item.get('title') tags = group_item.get('field_org_tags') uuid = group_item.get('uuid') nid = group_item.get('nid') - event_dict = { - 'event_name': event.get('name').get('text'), - 'group_name': group_name, - 'venue': venues[event.get('venue_id')], - 'url': event.get('url'), - 'time': event.get('start').get("utc"), - 'tags': tags, - 'rsvp_count': None, - 'created_at': event.get('created'), - 'description': event.get('description').get('text'), - 'uuid': uuid, - 'nid': nid, - 'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), - 'status': normalize_eventbrite_status_codes(event.get('status')) - } + if type(event.get('venue_id')) == str: + event_dict = { + 'event_name': event.get('name').get('text'), + 'group_name': group_name, + 'venue': venues[event.get('venue_id')], + 'url': event.get('url'), + 'time': event.get('start').get("utc"), + 'tags': tags, + 'rsvp_count': None, + 'created_at': event.get('created'), + 'description': event.get('description').get('text'), + 'uuid': uuid, + 'nid': nid, + 'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), + 'status': normalize_eventbrite_status_codes(event.get('status')) + } + elif event.get('venue_id') == None: # if event venue is None, it is online/virtual + event_dict = { + 'event_name': event.get('name').get('text'), + 'group_name': group_name, + 'venue': event.get('venue_id'), + 'url': event.get('url'), + 'time': event.get('start').get("utc"), + 'tags': tags, + 'rsvp_count': None, + 'created_at': event.get('created'), + 'description': event.get('description').get('text'), + 'uuid': uuid, + 'nid': nid, + 'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), + 'status': normalize_eventbrite_status_codes(event.get('status')) + } events.append(event_dict) - return events @@ -317,7 +334,6 @@ def get_dates(): # Sort events by time events.sort(key=lambda s: s['time']) - return jsonify(events) diff --git a/update_cal_data.py b/update_cal_data.py index c6c891a..ad2cbd3 100644 --- a/update_cal_data.py +++ b/update_cal_data.py @@ -18,7 +18,6 @@ def refresh_all_meetings(): ) with open('all_meetings.json', 'w') as outfile: json.dump(events, outfile) - return events From 58c9fa2f98adcbcdab828fac47e39136c9333bea Mon Sep 17 00:00:00 2001 From: RamonaEJSpence Date: Tue, 12 May 2020 14:22:52 -0400 Subject: [PATCH 3/3] edited days_in_the_past var --- app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 3e777ce..e664731 100644 --- a/app.py +++ b/app.py @@ -142,7 +142,7 @@ def get_eventbrite_events(group_list): events = [] # Number of days to allow for past events - days_in_the_past = config.get('past_events', 'past_days') + days_in_the_past = config.get('past_events', 'days_in_the_past') # the current date time in ISO8601 format current_time = (datetime.datetime.utcnow()) @@ -276,7 +276,7 @@ def parse_date(d): def filter_events_by_date(events, start_date_str=datetime.datetime.now(datetime.timezone.utc), end_date_str=None): # number of days specified in config - days_in_the_past = config.get('past_events', 'past_days') + days_in_the_past = config.get('past_events', 'days_in_the_past') if start_date_str: start_date = parse_date(start_date_str) - datetime.timedelta(days_in_the_past)