serJD commited on
Commit
a3c0add
·
verified ·
1 Parent(s): ab82e83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -24
app.py CHANGED
@@ -169,36 +169,27 @@ async def update_streams(request: Request):
169
 
170
  payload = payload["payload"]
171
  # Check if the payload structure matches the expected format
172
- if "event" in payload and "data" in payload["event"]:
173
- event_data = payload["event"]["data"]
174
-
175
- # Check if the event type is one of the specified types
176
- if "event_name" in payload["event"] and payload["event"]["event_name"] in ["commit_create", "commit_delete", "commit_update"]:
177
- # Check if the stream name matches the specified list
178
- if "stream" in payload and payload["stream"]["name"] in config.keys():
179
- streamName = payload["stream"]["name"]
180
- # Check if the branch name matches the specified list
181
- if "commit" in event_data and "branchName" in event_data["commit"]:
182
- branchName = event_data["commit"]["branchName"]
183
- # Attempt to load the configuration for the stream and branch
184
- try:
185
- stream_config = config[streamName][branchName]
186
- should_continue = True
187
- # You can now use stream_config for further processing
188
- except KeyError:
189
- print(f"Configuration for stream {streamName} and branch {branchName} not found.")
190
- else:
191
- print("Branch name not found in payload.")
192
  else:
193
- print("Stream name not found or not in the specified list.")
194
  else:
195
- print("Event type is not one of the specified types.")
196
  else:
197
- print("Payload structure does not match the expected format.")
198
 
199
  # If the flag is True, continue running the main part of the code
200
  if should_continue:
201
  locals().update(config[streamName, branchName])
202
 
203
- # Your main code logic goes here
204
  mainFunc(STREAM_ID, SOURCE_BRANCH, TARGET_BRANCH, UUID_COL, ATTR_METADATA, KPI_METADATA, DEFAULT_ATTRIBUTES)
 
169
 
170
  payload = payload["payload"]
171
  # Check if the payload structure matches the expected format
172
+ # Assuming payload["event"]["event_name"] gives you the event type
173
+ event_name = payload["event"]["event_name"]
174
+
175
+ # List of valid event types
176
+ valid_event_types = ["commit_create", "commit_delete", "commit_update"]
177
+
178
+ if event_name in valid_event_types:
179
+ if streamName in config:
180
+ if branchName in config[streamName]:
181
+ stream_config = config[streamName][branchName]
182
+ should_continue = True
 
 
 
 
 
 
 
 
 
183
  else:
184
+ print(f"Branch name {branchName} not found in config for stream {streamName}.")
185
  else:
186
+ print(f"Stream name {streamName} not found in config.")
187
  else:
188
+ print(f"Event type {event_name} is not one of the specified types.")
189
 
190
  # If the flag is True, continue running the main part of the code
191
  if should_continue:
192
  locals().update(config[streamName, branchName])
193
 
194
+ # main
195
  mainFunc(STREAM_ID, SOURCE_BRANCH, TARGET_BRANCH, UUID_COL, ATTR_METADATA, KPI_METADATA, DEFAULT_ATTRIBUTES)