in src/main/scala/com/gu/dynamodbswitches/Switches.scala [77:92]
def process(updates: List[Map[String, AttributeValue]]): ProcessingResults = {
val switchesAndStates = (updates flatMap { attributeMap =>
for {
keyAttribute <- attributeMap.get(DynamoDbKeyName)
key <- Option(keyAttribute.s())
enabledAttribute <- attributeMap.get(DynamoDbValueName)
enabled <- Option(enabledAttribute.n()).map(_.toInt == 1)
switch <- byName.get(key)
} yield switch -> enabled
}).toSet
ProcessingResults(
switchesAndStates filter { case (switch, state) => switch.enabled != state },
switchSet.diff(switchesAndStates.map(_._1).toSet)
)
}