def lambdaHandler()

in backend/lambda/question-stream/lambda.py [0:0]


def lambdaHandler(event, context):
    print("Received event: " + json.dumps(event, indent=2))
    
    processedRecords = processRecords(event['Records'])
    uniqueChannels = list(set([r['question']['ChannelArn'] for r in processedRecords]))

    connectionsPerChannel = fetchChannelConnections(uniqueChannels)

    recordsPerChannel = {
        c: [r for r in processedRecords if r['question']['ChannelArn'] == c] for c in uniqueChannels
    }
    
    sendRecordsToConnections(recordsPerChannel, connectionsPerChannel)