<commit_before>const Promise = require('bluebird')
const config = require('../../../knexfile').extweb
const knex = require('knex')(config)
const insertTask = require('./insert-task')
const insertTaskSendClaimNotification = require('./insert-task-send-claim-notification')
const tasksEnum = require('../../constants/tasks-enum')
const eligibilityStatusEnum = require('../../constants/eligibility-status-enum')
const claimStatusEnum = require('../../constants/claim-status-enum')
const dateFormatter = require('../date-formatter')

module.exports = function (reference, eligibilityId, claimId, claimType, assistedDigitalCaseworker) {
  var dateSubmitted = dateFormatter.now().toDate()

  return knex('Claim')
    .where({'Reference': reference, 'EligibilityId': eligibilityId, 'ClaimId': claimId, 'Status': claimStatusEnum.IN_PROGRESS})
    .first('ClaimId')
    .then(function (result) {
      if (!result) {
        throw new Error(`Could not find Claim reference: ${reference} - claimId: ${claimId} - status: IN-PROGRESS`)
      }

      return Promise.all([updateEligibility(reference, eligibilityId, dateSubmitted),
                          updateClaim(claimId, dateSubmitted, assistedDigitalCaseworker),
                          insertTask(reference, eligibilityId, claimId, tasksEnum.COMPLETE_CLAIM, claimType),
                          insertTaskSendClaimNotification(reference, eligibilityId, claimId)])
    })
}

function updateEligibility (reference, eligibilityId, dateSubmitted) {
  return knex('Eligibility').where({'Reference': reference, 'EligibilityId': eligibilityId}).update({
    'Status': eligibilityStatusEnum.SUBMITTED,
    'DateSubmitted': dateSubmitted
  })
}

function updateClaim (claimId, dateSubmitted, assistedDigitalCaseworker) {
  return knex('Claim').where('ClaimId', claimId).update({
    'Status': claimStatusEnum.SUBMITTED,
    'DateSubmitted': dateSubmitted,
    'AssistedDigitalCaseworker': assistedDigitalCaseworker
  })
}<commit_msg>corrected standard error thrown on travis<commit_after>const Promise = require('bluebird')
const config = require('../../../knexfile').extweb
const knex = require('knex')(config)
const insertTask = require('./insert-task')
const insertTaskSendClaimNotification = require('./insert-task-send-claim-notification')
const tasksEnum = require('../../constants/tasks-enum')
const eligibilityStatusEnum = require('../../constants/eligibility-status-enum')
const claimStatusEnum = require('../../constants/claim-status-enum')
const dateFormatter = require('../date-formatter')

module.exports = function (reference, eligibilityId, claimId, claimType, assistedDigitalCaseworker) {
  var dateSubmitted = dateFormatter.now().toDate()

  return knex('Claim')
    .where({'Reference': reference, 'EligibilityId': eligibilityId, 'ClaimId': claimId, 'Status': claimStatusEnum.IN_PROGRESS})
    .first('ClaimId')
    .then(function (result) {
      if (!result) {
        throw new Error(`Could not find Claim reference: ${reference} - claimId: ${claimId} - status: IN-PROGRESS`)
      }

      return Promise.all([updateEligibility(reference, eligibilityId, dateSubmitted),
        updateClaim(claimId, dateSubmitted, assistedDigitalCaseworker),
        insertTask(reference, eligibilityId, claimId, tasksEnum.COMPLETE_CLAIM, claimType),
        insertTaskSendClaimNotification(reference, eligibilityId, claimId)])
    })
}

function updateEligibility (reference, eligibilityId, dateSubmitted) {
  return knex('Eligibility').where({'Reference': reference, 'EligibilityId': eligibilityId}).update({
    'Status': eligibilityStatusEnum.SUBMITTED,
    'DateSubmitted': dateSubmitted
  })
}

function updateClaim (claimId, dateSubmitted, assistedDigitalCaseworker) {
  return knex('Claim').where('ClaimId', claimId).update({
    'Status': claimStatusEnum.SUBMITTED,
    'DateSubmitted': dateSubmitted,
    'AssistedDigitalCaseworker': assistedDigitalCaseworker
  })
}
{'fraction_non_alphanumeric': 0.13717491075981642, 'fraction_numerical': 0.0, 'mean_word_length': 4.925981873111782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3289652', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1040, 'n_words': 219}