<commit_before>import bootstrap from '../bootstrap'

const handleResolveReadModelEvent = async (
  lambdaEvent,
  { lambda, executeQuery, readModels }
) => {
  switch (lambdaEvent.operation) {
    case 'reset':
    case 'pause':
    case 'resume': {
      const names = lambdaEvent.name
        ? [lambdaEvent.name]
        : readModels.map(readModel => readModel.name)
      const { DEPLOYMENT_ID } = process.env
      for (const name of names) {
        await lambda
          .invoke({
            FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
            Payload: JSON.stringify({
              listenerId: name,
              operation: lambdaEvent.operation
            })
          })
          .promise()

        if (lambdaEvent.operation === 'reset') {
          await executeQuery.drop(name)
        }
      }
      return 'ok'
    }
    case 'list': {
      const { DEPLOYMENT_ID } = process.env

      return Promise.all(
        readModels.map(async readModel => {
          const state = await lambda
            .invoke({
              FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
              Payload: JSON.stringify({
                listenerId: lambda.name,
                operation: 'status'
              })
            })
            .promise()

          return {
            ...state,
            name: readModel.name
          }
        })<commit_msg>Fix listener id for status request<commit_after>import bootstrap from '../bootstrap'

const handleResolveReadModelEvent = async (
  lambdaEvent,
  { lambda, executeQuery, readModels }
) => {
  switch (lambdaEvent.operation) {
    case 'reset':
    case 'pause':
    case 'resume': {
      const names = lambdaEvent.name
        ? [lambdaEvent.name]
        : readModels.map(readModel => readModel.name)
      const { DEPLOYMENT_ID } = process.env
      for (const name of names) {
        await lambda
          .invoke({
            FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
            Payload: JSON.stringify({
              listenerId: name,
              operation: lambdaEvent.operation
            })
          })
          .promise()

        if (lambdaEvent.operation === 'reset') {
          await executeQuery.drop(name)
        }
      }
      return 'ok'
    }
    case 'list': {
      const { DEPLOYMENT_ID } = process.env

      return Promise.all(
        readModels.map(async readModel => {
          const state = await lambda
            .invoke({
              FunctionName: `${DEPLOYMENT_ID}-meta-lock`,
              Payload: JSON.stringify({
                listenerId: readModel.name,
                operation: 'status'
              })
            })
            .promise()

          return {
            ...state,
            name: readModel.name
          }
        })
{'fraction_non_alphanumeric': 0.1095890410958904, 'fraction_numerical': 0.0, 'mean_word_length': 1.5552486187845305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4630689', 'n_tokens_mistral': 753, 'n_tokens_neox': 740, 'n_words': 163}