{"size": 754, "ext": "js", "max_stars_repo_path": "tools/get-rogue-bots.js", "max_stars_repo_name": "LeoPlatform/serverless-leo-tools", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tools/get-rogue-bots.js", "max_issues_repo_name": "LeoPlatform/serverless-leo-tools", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tools/get-rogue-bots.js", "max_forks_repo_name": "LeoPlatform/serverless-leo-tools", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.1333333333, "max_line_length": 81, "alphanum_fraction": 0.6273209549}

const AWS = require('aws-sdk')

module.exports = async function () {
  var documentClient = new AWS.DynamoDB.DocumentClient()
  // bots where errorCount > 10
  // not archived
  // must have trigger (time or trigger)
  var botsContainingParams = {
    TableName: this.config.table.bot,
    ScanFilter: {
      'errorCount': {
        ComparisonOperator: 'GT',
        AttributeValueList: [10]
      },
      'archived': {
        ComparisonOperator: 'NE',
        AttributeValueList: [true]
      }
    },
    Select: 'ALL_ATTRIBUTES'
  }

  const requireTrigger = ({ Items }) => {
    return Items.filter(i => ((i.triggers && i.triggers.length > 0) || (i.time)))
  }

  return documentClient.scan(botsContainingParams).promise().then(requireTrigger)
}
