@@ -215,9 +215,9 @@ private async Task<bool> JoinEventData(Event olEvent, string jobRunId)
215215 await Task . Delay ( delay ) ;
216216 }
217217
218- // Get inputs. Todo : Check if more efficient to get inputs within the same while loop above. Can we get 2 entities at the same time?
218+ // Get inputs. TODO : Check if more efficient to get inputs within the same while loop above. Can we get 2 entities at the same time?
219219 currentRetry = 0 ;
220- while ( ret_val ) // ret_val instead of just true, because if didn't have the env_facet then don't bother getting inputs either
220+ while ( ret_val ) // use a variable instead of just true, because if we didn't have the env_facet then we don't need to get inputs
221221 {
222222 try
223223 {
@@ -248,45 +248,36 @@ private async Task<bool> JoinEventData(Event olEvent, string jobRunId)
248248
249249 // Check if saved any inputs from the START event (will only be done for events containing DataSourceV2 sources)
250250 if ( te_inputs is not null ) {
251- // TODO: Possible source of error.
252- if ( te_inputs . ContainsKey ( "Inputs" ) ) {
253- _log . LogInformation ( $ "New Code #1") ;
251+
252+ if ( te_inputs . ContainsKey ( "Inputs" ) ) {
254253 try {
255- var saved_inputs = JsonConvert . DeserializeObject < List < Inputs > > ( te_inputs [ "Inputs" ] . ToString ( ) ?? "" ) ;
256- _log . LogInformation ( $ "New Code #1.1" ) ;
257- _log . LogInformation ( "Inputs in dictionary? " , te_inputs . ContainsKey ( "Inputs" ) . ToString ( ) ) ;
258-
259- if ( saved_inputs is null ) {
260- // Unecessary check?
261- _log . LogInformation ( $ "OlMessageConsolodation-JoinEventData: No inputs found for COMPLETE event") ;
262- //ret_val = false;
263- }
264-
265- else {
266- // Check inputs saved against inputs captured in this COMPLETE event and combine while removing any duplicates.
267- // Checking for duplicates needed since we save all the inputs captured from the START event. Perhaps it may be better to
268- // only save the DataSourceV2 inputs?
269- var inputs = new List < Inputs > ( saved_inputs . Count + olEvent . Inputs . Count ) ;
270- inputs . AddRange ( saved_inputs ) ;
271- inputs . AddRange ( olEvent . Inputs ) ;
272- var unique_inputs = inputs . Distinct ( ) ;
273- olEvent . Inputs = unique_inputs . ToList ( ) ;
274- _log . LogInformation ( $ "OlMessageConsolodation-JoinEventData: Captured inputs for COMPLETE event" ) ;
254+ //TODO: Find out why inputs might be null. Technically inputs are only added to the table if they exist. This is also not an issue when running locally.
255+ if ( te_inputs [ "Inputs" ] != null ) {
256+
257+ var saved_inputs = JsonConvert . DeserializeObject < List < Inputs > > ( te_inputs [ "Inputs" ] . ToString ( ) ?? "" ) ;
258+
259+ if ( saved_inputs is null ) {
260+ _log . LogInformation ( $ "OlMessageConsolodation-JoinEventData: No inputs found for COMPLETE event") ;
261+ }
262+
263+ else {
264+ // Check inputs saved against inputs captured in this COMPLETE event and combine while removing any duplicates.
265+ // Checking for duplicates needed since we save all the inputs captured from the START event. Perhaps it may be better to
266+ // only save the DataSourceV2 inputs?
267+ var inputs = new List < Inputs > ( saved_inputs . Count + olEvent . Inputs . Count ) ;
268+ inputs . AddRange ( saved_inputs ) ;
269+ inputs . AddRange ( olEvent . Inputs ) ;
270+ var unique_inputs = inputs . Distinct ( ) ;
271+ olEvent . Inputs = unique_inputs . ToList ( ) ;
272+ _log . LogInformation ( $ "OlMessageConsolodation-JoinEventData: Captured inputs for COMPLETE event" ) ;
273+ }
275274 }
276275 }
277276 catch ( System . Exception ex ) {
278277 _log . LogError ( ex , $ "OlMessageConsolodation-JoinEventData: Error { ex . Message } when deserializing inputs") ;
279278 ret_val = false ;
280279 }
281280
282-
283-
284- }
285-
286- else {
287- _log . LogInformation ( $ "New Code #2") ;
288- _log . LogInformation ( $ "OlMessageConsolodation-JoinEventData: No inputs found for COMPLETE event") ;
289- //ret_val = false;
290281 }
291282
292283 }
@@ -301,9 +292,9 @@ private async Task<bool> JoinEventData(Event olEvent, string jobRunId)
301292 _log . LogError ( ex , $ "OlMessageConsolodation-JoinEventData: Error { ex . Message } when deleting entity") ;
302293 }
303294
304- // If no inputs were saved from the start event, then we need to make sure we're only processing this COMPLETE event
305- // if it has both inputs and outputs (reflects original logic, prior to supporting DataSourceV2 events)
306- if ( te_inputs is null && ! ( olEvent . Inputs . Count > 0 && olEvent . Outputs . Count > 0 ) ) {
295+ // Need to make sure we're only processing this COMPLETE event if it has both
296+ // inputs and outputs (reflects original logic, prior to supporting DataSourceV2 events)
297+ if ( ! ( olEvent . Inputs . Count > 0 && olEvent . Outputs . Count > 0 ) ) {
307298 ret_val = false ;
308299 }
309300
@@ -314,9 +305,9 @@ private async Task<bool> JoinEventData(Event olEvent, string jobRunId)
314305 private bool IsStartEventEnvironment ( Event olEvent )
315306 {
316307 if ( olEvent . EventType == START_EVENT && olEvent . Run . Facets . EnvironmentProperties != null )
317- {
318- return true ;
319- }
308+ {
309+ return true ;
310+ }
320311
321312 return false ;
322313 }
0 commit comments