Guest User

Untitled

a guest
Jan 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. // Original
  2. const subscriptionData = (getKey(['stack','componentInstances'])(liveOrLastDeployment) || []).reduce(
  3. (compAgg, compCurrent) => compAgg.concat(
  4. (compCurrent.functionInstances || []).reduce((agg, curr) => agg.concat(curr.subscriptions || []), [])
  5. ), []
  6. ).concat(
  7. (getKey(['stack','functionInstances'])(liveOrLastDeployment) || []).reduce((agg, curr) => agg.concat(curr.subscriptions || []), [])
  8. )
  9.  
  10. /**********************/
  11.  
  12. // Extra crispy (New)
  13.  
  14. // get graphql data
  15. const componentInstances = getKey(['stack','componentInstances'])(liveOrLastDeployment) || []
  16. const functionInstances = getKey(['stack','functionInstances'])(liveOrLastDeployment) || []
  17.  
  18. // Get sub data from components
  19. const componentSubData = componentInstances.reduce((compAgg, compCurrent) => {
  20. const functionInstances = compCurrent.functionInstances || []
  21. const subs = curr.subscriptions || []
  22. return compAgg.concat(functionInstances.reduce((agg, curr) => {
  23. return agg.concat(curr.subscriptions || [])
  24. }, [])
  25. }), [])
  26.  
  27. // Get sub data from functions
  28. const functionSubData = functionInstances.reduce((agg, curr) => {
  29. const otherSubs = curr.subscriptions || []
  30. return agg.concat(otherSubs)
  31. }, [])
  32.  
  33. // Merge subscription data
  34. const SubscriptionData = componentSubData.concat(functionSubData)
Add Comment
Please, Sign In to add comment