<commit_before>import { ObjectID as objectId } from 'mongodb';
import omit from 'lodash/omit';
import { route, MongoResourceRouter } from 'makeen-router';
import listSchema from '../schemas/list';

class ListsRouter extends MongoResourceRouter {
  constructor(ListRepository, config = {}) {
    super(ListRepository, {
      namespace: 'TodoLists',
      basePath: '/lists',
      getRepository: (request, reply) => reply(request.server.plugins['makeen-todo'].ListRepository),
      entitySchema: omit(listSchema, [
        '_id', 'createdBy', 'createdAt', 'updatedAt', 'accountId',
      ]),
      ...config,
    });

    this.applyContext({
      generateContext: (request) => ({
        accountId: objectId(request.auth.credentials.accountId),
      }),
    });

    this.ListRepository = ListRepository;

    this.routes.createOne.config.pre.push({
      async method(request, reply) {
        Object.assign(request.pre.payload, {
          createdBy: objectId(request.auth.credentials.id),
        });

        reply();
      },
    });
  }

  @route.get({
    path: 'find-with-stats',
    method: 'GET',
    config: {
      description: 'Find lists with stats and items',
    },
  })
  findWithStats(request) {
    const accountId = objectId(request.auth.credentials.accountId);

    return this.ListRepository.findManyWithStats({
      query: { accountId },
    });<commit_msg>remove leftover<commit_after>import { ObjectID as objectId } from 'mongodb';
import omit from 'lodash/omit';
import { route, MongoResourceRouter } from 'makeen-router';
import listSchema from '../schemas/list';

class ListsRouter extends MongoResourceRouter {
  constructor(ListRepository, config = {}) {
    super(ListRepository, {
      namespace: 'TodoLists',
      basePath: '/lists',
      entitySchema: omit(listSchema, [
        '_id',
        'createdBy',
        'createdAt',
        'updatedAt',
        'accountId',
      ]),
      ...config,
    });

    this.applyContext({
      generateContext: request => ({
        accountId: objectId(request.auth.credentials.accountId),
      }),
    });

    this.ListRepository = ListRepository;

    this.routes.createOne.config.pre.push({
      async method(request, reply) {
        Object.assign(request.pre.payload, {
          createdBy: objectId(request.auth.credentials.id),
        });

        reply();
      },
    });
  }

  @route.get({
    path: 'find-with-stats',
    method: 'GET',
    config: {
      description: 'Find lists with stats and items',
    },
  })
  findWithStats(request) {
    const accountId = objectId(request.auth.credentials.accountId);

    return this.ListRepository.findManyWithStats({
      query: { accountId },
    });
{'fraction_non_alphanumeric': 0.14047442550037065, 'fraction_numerical': 0.0, 'mean_word_length': 2.8392603129445235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3811685', 'n_tokens_mistral': 809, 'n_tokens_neox': 778, 'n_words': 153}