Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Original
- const subscriptionData = (getKey(['stack','componentInstances'])(liveOrLastDeployment) || []).reduce(
- (compAgg, compCurrent) => compAgg.concat(
- (compCurrent.functionInstances || []).reduce((agg, curr) => agg.concat(curr.subscriptions || []), [])
- ), []
- ).concat(
- (getKey(['stack','functionInstances'])(liveOrLastDeployment) || []).reduce((agg, curr) => agg.concat(curr.subscriptions || []), [])
- )
- /**********************/
- // Extra crispy (New)
- // get graphql data
- const componentInstances = getKey(['stack','componentInstances'])(liveOrLastDeployment) || []
- const functionInstances = getKey(['stack','functionInstances'])(liveOrLastDeployment) || []
- // Get sub data from components
- const componentSubData = componentInstances.reduce((compAgg, compCurrent) => {
- const functionInstances = compCurrent.functionInstances || []
- const subs = curr.subscriptions || []
- return compAgg.concat(functionInstances.reduce((agg, curr) => {
- return agg.concat(curr.subscriptions || [])
- }, [])
- }), [])
- // Get sub data from functions
- const functionSubData = functionInstances.reduce((agg, curr) => {
- const otherSubs = curr.subscriptions || []
- return agg.concat(otherSubs)
- }, [])
- // Merge subscription data
- const SubscriptionData = componentSubData.concat(functionSubData)
Add Comment
Please, Sign In to add comment