<commit_before>import createService from 'feathers-objection'
import { disallow, iffElse } from 'feathers-hooks-common/lib'

import Farm from '../models/farms'
import toGeoJSON from '../hooks/geoJson'
import {
  entryColumns,
  selectActiveEntries,
  relate,
  relateOwner,
  selectEntryColumns,
  withEager
} from '../hooks/relations'
import { setCreatedAt, setUpdatedAt } from '../hooks/audit'
import { sendNewEntryNotification } from '../hooks/email'
import filterAllowedFields from '../hooks/filterAllowedFields'

export default app => {
  const service = createService({
    model: Farm,
    allowedEager: '[depots, products, ownerships]',
    whitelist: ['$eager', '$select'],
    eagerFilters: [
      {
        expression: 'depots',
        filter: builder => {
          builder.select(entryColumns('depots'))
        }
      },
      {
        expression: 'products',
        filter: builder => {
          builder.select(['products.id', 'category', 'name'])
        }
      },
      {
        expression: 'ownerships',
        filter: builder => {
          builder.select(['users.id', 'email', 'name', 'origin', 'baseurl'])
        }
      }
    ]
  })

  app.use('/farms', service)

  app
    .service('farms')
    .hooks({
      before: {
        all: [],
        find: [
          iffElse(
            ctx => ctx.params.query.$details !== 'true',
            [withEager('[products]'), selectEntryColumns],
            [withEager('[depots, products]')]
          ),
          selectActiveEntries
        ],
        get: [
          ctx => {
            ctx.params.query = null
          },
          withEager('[depots, products]'),
          selectActiveEntries
        ],
        create: [setCreatedAt],
        update: [disallow()],
        patch: [setUpdatedAt],
        remove: []
      },
      after: {
        all: [],
        find: [],
        get: [],
        create: [
          relate(Farm, 'products'),
          relate(Farm, 'depots'),
          relateOwner,
          sendNewEntryNotification
        ],
        patch: [relate(Farm, 'products'), relate(Farm, 'depots')],
        remove: []
      },
      error: {
        all: [],
        find: [],
        get: [],
        create: [],
        patch: [],
        remove: []
      }
    })
    .hooks({ after: { all: [filterAllowedFields, toGeoJSON('depots')] } })
}<commit_msg>Bug: Remove debug hook<commit_after>import createService from 'feathers-objection'
import { disallow, iffElse } from 'feathers-hooks-common/lib'

import Farm from '../models/farms'
import toGeoJSON from '../hooks/geoJson'
import {
  entryColumns,
  selectActiveEntries,
  relate,
  relateOwner,
  selectEntryColumns,
  withEager
} from '../hooks/relations'
import { setCreatedAt, setUpdatedAt } from '../hooks/audit'
import { sendNewEntryNotification } from '../hooks/email'
import filterAllowedFields from '../hooks/filterAllowedFields'

export default app => {
  const service = createService({
    model: Farm,
    allowedEager: '[depots, products, ownerships]',
    whitelist: ['$eager', '$select'],
    eagerFilters: [
      {
        expression: 'depots',
        filter: builder => {
          builder.select(entryColumns('depots'))
        }
      },
      {
        expression: 'products',
        filter: builder => {
          builder.select(['products.id', 'category', 'name'])
        }
      },
      {
        expression: 'ownerships',
        filter: builder => {
          builder.select(['users.id', 'email', 'name', 'origin', 'baseurl'])
        }
      }
    ]
  })

  app.use('/farms', service)

  app
    .service('farms')
    .hooks({
      before: {
        all: [],
        find: [
          iffElse(
            ctx => ctx.params.query.$details !== 'true',
            [withEager('[products]'), selectEntryColumns],
            [withEager('[depots, products]')]
          ),
          selectActiveEntries
        ],
        get: [withEager('[depots, products]'), selectActiveEntries],
        create: [setCreatedAt],
        update: [disallow()],
        patch: [setUpdatedAt],
        remove: []
      },
      after: {
        all: [],
        find: [],
        get: [],
        create: [
          relate(Farm, 'products'),
          relate(Farm, 'depots'),
          relateOwner,
          sendNewEntryNotification
        ],
        patch: [relate(Farm, 'products'), relate(Farm, 'depots')],
        remove: []
      },
      error: {
        all: [],
        find: [],
        get: [],
        create: [],
        patch: [],
        remove: []
      }
    })
    .hooks({ after: { all: [filterAllowedFields, toGeoJSON('depots')] } })
}
{'fraction_non_alphanumeric': 0.15595933376595283, 'fraction_numerical': 0.0, 'mean_word_length': 1.9736334405144695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '2194700', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1376, 'n_words': 272}