<commit_before>'use strict'

const _ = require('lodash')
const lib = require('.')

module.exports = {

  /**
   * Compile controller handlers into route objects
   */
  getControllerFootprints (app) {
    const controllers = _.omit(app.controllers, _.get(app.config, 'footprints.controllers.ignore'))
    const prefix = _.get(app.config, 'footprints.prefix')

    return _.flatten(_.map(controllers, (controller, controllerName) => {
      const controllerMantissa = lib.Util.getControllerMantissa(controllerName)

      return _.map(controller.methods, handlerName => {
        return {
          method: _.get(app.config, 'footprints.controllers.method') || [ 'GET', 'POST' ],
          path: lib.Util.getHandlerPath(app, prefix, controllerMantissa, handlerName),
          handler: lib.Util.getControllerHandler(controllerName, handlerName)
        }
      })
    }))
  },

  /**
   * Select the model footprint routes that the configuration allows.
   */
  getModelFootprints (app) {
    const actionsConfig = _.get(app.config, 'footprints.models.actions')

    return _.filter(lib.Routes, route => {
      const handlerName = lib.Util.getHandlerName(route.handler)
      return actionsConfig[handlerName]
    })
  },

  getControllerMantissa (controllerName) {
    return controllerName.replace(/(\w+)Controller/, '$1').toLowerCase()
  },

  getControllerHandler (controllerName, handlerName) {
    return `${controllerName}.${handlerName}`
  },

  getHandlerName (routeHandler) {
    return (routeHandler || '').split('.')[1]
  },

  getHandlerPath (app, prefix, controllerMantissa, handlerName) {
    return app.packs.router.util.getRoutePath([
      '/', prefix, controllerMantissa, handlerName
    ])
  }
}<commit_msg>[cleanup] moved getControllerMantissa to trails-controller<commit_after>'use strict'

const _ = require('lodash')
const lib = require('.')

module.exports = {

  /**
   * Compile controller handlers into route objects
   */
  getControllerFootprints (app) {
    const controllers = _.omit(app.controllers, _.get(app.config, 'footprints.controllers.ignore'))
    const prefix = _.get(app.config, 'footprints.prefix')

    return _.flatten(_.map(controllers, (controller, controllerName) => {

      return _.map(controller.methods, handlerName => {
        return {
          method: _.get(app.config, 'footprints.controllers.method') || [ 'GET', 'POST' ],
          path: lib.Util.getHandlerPath(app, prefix, controller.id, handlerName),
          handler: lib.Util.getControllerHandler(controllerName, handlerName)
        }
      })
    }))
  },

  /**
   * Select the model footprint routes that the configuration allows.
   */
  getModelFootprints (app) {
    const actionsConfig = _.get(app.config, 'footprints.models.actions')

    return _.filter(lib.Routes, route => {
      const handlerName = lib.Util.getHandlerName(route.handler)
      return actionsConfig[handlerName]
    })
  },

  getControllerHandler (controllerName, handlerName) {
    return `${controllerName}.${handlerName}`
  },

  getHandlerName (routeHandler) {
    return (routeHandler || '').split('.')[1]
  },

  getHandlerPath (app, prefix, controllerId, handlerName) {
    return app.packs.router.util.getRoutePath([
      '/', prefix, controllerId, handlerName
    ])
  }
}
{'fraction_non_alphanumeric': 0.13658536585365855, 'fraction_numerical': 0.0009146341463414635, 'mean_word_length': 3.531767955801105, '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': '2673113', 'n_tokens_mistral': 968, 'n_tokens_neox': 943, 'n_words': 190}