<commit_before>const knex = require('../../../knex').web

module.exports = function (id) {
  const selectList = [
    'tierCode',
    'rowType',
    'caseReferenceNo',
    'caseType',
    'inCustody',
    'registerLevel',
    'registerCategory',
    'registerCategoryDescription',
    'registrationDate'
  ]

  return knex('case_details_view')
    .withSchema('app')
    .columns(selectList)
    .where('workloadOwnerId', id)
    .then(function (results) {
      if (results.length > 0) {
        results.forEach(function (result) {
          formatSuspendedLiferFields(result)
        })
      }
      return results
    })
}

const formatSuspendedLiferFields = function (result) {
  if (result.rowType !== 'Suspended Lifer') {
    result.inCustody = 'N/A'
    result.registerLevel = 'N/A'
    result.registerCategory = 'N/A'
    result.registerCategoryDescription = 'N/A'
    result.registrationDate = 'N/A'
  } else {
    if (result.inCustody === 'N') {
      result.inCustody = 'No'
    } else if (result.inCustody === 'Y') {
      result.inCustody = 'Yes'
    }
    if (result.registrationDate) {
      const newDate = new Date(result.registrationDate)
      const year = newDate.getFullYear()
      let month = newDate.getMonth() + 1
      const dt = newDate.getDate()
      if (month < 10) {
        month = '0' + month
      }
      result.registrationDate = dt + '/' + month + '/' + year
    }
  }
}
<commit_msg>fixed query due to case issue<commit_after>const knex = require('../../../knex').web

module.exports = function (id) {
  const selectList = [
    'tiercode as tierCode',
    'rowtype as rowType',
    'casereferenceno as caseReferenceNo',
    'casetype as caseType',
    'incustody as inCustody',
    'registerlevel as registerLevel',
    'registercategory as registerCategory',
    'registercategorydescription as registerCategoryDescription',
    'registrationdate as registrationDate'
  ]

  return knex('case_details_view')
    .withSchema('app')
    .columns(selectList)
    .where('workloadownerid', id)
    .then(function (results) {
      if (results.length > 0) {
        results.forEach(function (result) {
          formatSuspendedLiferFields(result)
        })
      }
      return results
    })
}

const formatSuspendedLiferFields = function (result) {
  if (result.rowType !== 'Suspended Lifer') {
    result.inCustody = 'N/A'
    result.registerLevel = 'N/A'
    result.registerCategory = 'N/A'
    result.registerCategoryDescription = 'N/A'
    result.registrationDate = 'N/A'
  } else {
    if (result.inCustody === 'N') {
      result.inCustody = 'No'
    } else if (result.inCustody === 'Y') {
      result.inCustody = 'Yes'
    }
    if (result.registrationDate) {
      const newDate = new Date(result.registrationDate)
      const year = newDate.getFullYear()
      let month = newDate.getMonth() + 1
      const dt = newDate.getDate()
      if (month < 10) {
        month = '0' + month
      }
      result.registrationDate = dt + '/' + month + '/' + year
    }
  }
}

{'fraction_non_alphanumeric': 0.13674078991038832, 'fraction_numerical': 0.003318951211417192, 'mean_word_length': 2.657766990291262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1868739', 'n_tokens_mistral': 993, 'n_tokens_neox': 971, 'n_words': 201}