in backend/lambda/connection-stream/lambda.py [0:0]
def lambdaHandler(event, context):
print("Received event: " + json.dumps(event, indent=2))
insertRecords = [r for r in event['Records'] if r['eventName'] == 'INSERT']
if len(insertRecords) == 0:
return
connectionIds = [r['dynamodb']['NewImage']['Id']['S'] for r in insertRecords]
channels = [r['dynamodb']['NewImage']['ChannelArn']['S'] for r in insertRecords]
uniqueChannels = list(set(channels))
channelQuestions = fetchChannelQuestions(uniqueChannels)
sendQuestionsToConnections(zip(connectionIds, channels), channelQuestions)