|
31 | 31 | # Process for frontend to use it
|
32 | 32 | def process_events(all_events):
|
33 | 33 |
|
34 |
| - filtered_events = [] |
| 34 | + |
35 | 35 |
|
36 | 36 | print(len(all_events))
|
37 | 37 |
|
38 |
| - for event in all_events: |
39 |
| - |
40 |
| - # some events don't have a place, if they don't maybe just remove them for now and later try to get the place |
41 |
| - # TODO: find place from owner's location if place is not present |
42 |
| - if "place" not in event: |
43 |
| - # print("no place") |
44 |
| - # print(event) |
45 |
| - |
46 |
| - # don't add to filtered_events |
47 |
| - continue |
48 |
| - |
49 |
| - # some events have "place" but no "place.location" |
50 |
| - # this happens with some events that are imported to facebook from eventbrite |
51 |
| - # I.E. they have "owner" == Eventbrite |
52 |
| - # if this happens we can just exclude them from the facebook database collection |
53 |
| - # this might even be a good thing because if they are eventbrite events, it would be difficult to dedupe across collections anyways |
54 |
| - if "location" not in event["place"]: |
55 |
| - # print ("no location") |
56 |
| - # print(event) |
57 |
| - |
58 |
| - # don't add to filtered_events |
59 |
| - continue |
60 |
| - |
61 |
| - # change "zip" of place.location to "zipcode" |
62 |
| - if 'location' in event['place'] and 'zip' in event['place']['location']: |
63 |
| - event['place']['location']['zipcode'] = event['place']['location'].pop('zip') |
64 |
| - |
65 |
| - # if event does not have an endtime, give it an endtime 1 hour into the future |
66 |
| - if "end_time" not in event: |
67 |
| - # print("no end_time") |
68 |
| - event["end_time"] = (datetime.datetime.strptime(event["start_time"], '%Y-%m-%dT%H:%M:%S%z') + datetime.timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%S%z') |
69 |
| - # print(event["end_time"]) |
70 |
| - |
71 |
| - filtered_events.append(event) |
72 |
| - |
| 38 | + |
73 | 39 | # URL parameters for refreshing / updating events info, including subevents
|
74 | 40 | sub_event_call_args = {
|
75 | 41 | 'fields': ','.join(EVENT_FIELDS),
|
76 | 42 | # 'fields': "id,name,cover,description,start_time,end_time,place,event_times",
|
77 | 43 | 'access_token': app_access_token
|
78 | 44 | }
|
79 | 45 |
|
80 |
| - additional_events = [] |
| 46 | + complete_events = [] |
81 | 47 |
|
82 | 48 | # check for multiday events
|
83 | 49 | for event in all_events:
|
@@ -117,15 +83,60 @@ def process_events(all_events):
|
117 | 83 | # if sub_event['start_time'] != event['start_time']:
|
118 | 84 | # sub_event['duplicate_occurrence'] = True
|
119 | 85 |
|
120 |
| - additional_events.append(expanded_event_dict) |
| 86 | + # additional_events.append(expanded_event_dict) |
| 87 | + complete_events.append(expanded_event_dict) |
| 88 | + |
| 89 | + # finally we want to remove this top level event to prevent duplication, |
| 90 | + # so just don't add it to complete_events |
| 91 | + |
121 | 92 | # More expanded_event_dict stuff: --haki
|
122 |
| - # else: |
123 |
| - # expanded_event_dict.update({event['id']: event}) |
| 93 | + else: |
| 94 | + complete_events.append(event) |
| 95 | + # expanded_event_dict.update({event['id']: event}) |
| 96 | + |
| 97 | + # print("additional facebook events") |
| 98 | + # print(len(additional_events)) |
| 99 | + |
| 100 | + # filtered_events.extend(additional_events) |
| 101 | + |
| 102 | + filtered_events = [] |
| 103 | + |
| 104 | + for event in complete_events: |
| 105 | + |
| 106 | + # some events don't have a place, if they don't maybe just remove them for now and later try to get the place |
| 107 | + # TODO: find place from owner's location if place is not present |
| 108 | + if "place" not in event: |
| 109 | + # print("no place") |
| 110 | + # print(event) |
| 111 | + |
| 112 | + # don't add to filtered_events |
| 113 | + continue |
| 114 | + |
| 115 | + # some events have "place" but no "place.location" |
| 116 | + # this happens with some events that are imported to facebook from eventbrite |
| 117 | + # I.E. they have "owner" == Eventbrite |
| 118 | + # if this happens we can just exclude them from the facebook database collection |
| 119 | + # this might even be a good thing because if they are eventbrite events, it would be difficult to dedupe across collections anyways |
| 120 | + if "location" not in event["place"]: |
| 121 | + # print ("no location") |
| 122 | + # print(event) |
| 123 | + |
| 124 | + # don't add to filtered_events |
| 125 | + continue |
| 126 | + |
| 127 | + # change "zip" of place.location to "zipcode" |
| 128 | + if 'location' in event['place'] and 'zip' in event['place']['location']: |
| 129 | + event['place']['location']['zipcode'] = event['place']['location'].pop('zip') |
| 130 | + |
| 131 | + # if event does not have an endtime, give it an endtime 1 hour into the future |
| 132 | + if "end_time" not in event: |
| 133 | + # print("no end_time") |
| 134 | + event["end_time"] = (datetime.datetime.strptime(event["start_time"], '%Y-%m-%dT%H:%M:%S%z') + datetime.timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%S%z') |
| 135 | + # print(event["end_time"]) |
| 136 | + |
| 137 | + filtered_events.append(event) |
124 | 138 |
|
125 |
| - print("additional facebook events") |
126 |
| - print(len(additional_events)) |
127 | 139 |
|
128 |
| - filtered_events.extend(additional_events) |
129 | 140 |
|
130 | 141 | print("filtered facebook events")
|
131 | 142 | print(len(filtered_events))
|
|
0 commit comments