Skip to content

Commit

Permalink
Remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Aug 30, 2023
1 parent a455c31 commit e16453e
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions app/table-streams/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {
DynamoDBRecord,
AttributeValue as LambdaTriggerAttributeValue,
} from 'aws-lambda'
import { inspect } from 'node:util'

import { sendEmailBulk } from '~/lib/email.server'
import { createTriggerHandler } from '~/lib/lambdaTrigger.server'
Expand Down Expand Up @@ -107,22 +106,19 @@ async function send(circular: Circular) {

// FIXME: must use module.exports here for OpenTelemetry shim to work correctly.
// See https://dev.to/heymarkkop/how-to-solve-cannot-redefine-property-handler-on-aws-lambda-3j67
module.exports.handler = createTriggerHandler(async (event: DynamoDBRecord) => {
// FIXME: Temporarily log the event. Trying to rule out duplicate Lambda
// invocations for https://github.com/nasa-gcn/gcn.nasa.gov/issues/924.
console.log(inspect(event, { depth: null }))
const { eventName, dynamodb } = event
module.exports.handler = createTriggerHandler(
async ({ eventName, dynamodb }: DynamoDBRecord) => {
const id = unmarshallTrigger(dynamodb!.Keys).circularId as number
const promises = []

const id = unmarshallTrigger(dynamodb!.Keys).circularId as number
const promises = []
if (eventName === 'REMOVE') {
promises.push(removeIndex(id))
} /* (eventName === 'INSERT' || eventName === 'MODIFY') */ else {
const circular = unmarshallTrigger(dynamodb!.NewImage) as Circular
promises.push(putIndex(circular))
if (eventName === 'INSERT') promises.push(send(circular))
}

if (eventName === 'REMOVE') {
promises.push(removeIndex(id))
} /* (eventName === 'INSERT' || eventName === 'MODIFY') */ else {
const circular = unmarshallTrigger(dynamodb!.NewImage) as Circular
promises.push(putIndex(circular))
if (eventName === 'INSERT') promises.push(send(circular))
await Promise.all(promises)
}

await Promise.all(promises)
})
)

0 comments on commit e16453e

Please sign in to comment.