<commit_before>import Card from '../models/card.model'
import Tag from '../models/tag.model'
import { testCard } from '../seed_data'

const debug = require('debug')('api:controllers:card.controller')

export const list = (req, res, next) => {
    debug("list called")
    Card.list()
        .then(cards => res.json(cards))
        .catch(e => next(e))
}

export const getBySlug = (req, res, next) => {
    debug("getBySlug called")
    Card.getBySlug(req.params.slug)
        .then(card => res.json(card))
        .catch(e => next(e))
}

export const seedCard = () => {
    Card.list().then(cards => {
        if (cards.length === 0) {
            Tag.findOne().exec()
                .then(tag => {
                    if (tag) {
                        Card.create({
                            ...testCard,
                            tags: [tag._id]    
                        })
                    }
                    else {
                        debug('no tag found')
                    }
                })
        }
    })
}<commit_msg>add debug in card controller<commit_after>import Card from '../models/card.model'
import Tag from '../models/tag.model'
import { testCard } from '../seed_data'

const debug = require('debug')('api:controllers:card.controller')

export const list = (req, res, next) => {
    debug("list called")
    Card.list()
        .then(cards => res.json(cards))
        .catch(e => next(e))
}

export const getBySlug = (req, res, next) => {
    debug("getBySlug called")
    Card.getBySlug(req.params.slug)
        .then(card => res.json(card))
        .catch(e => next(e))
}

export const seedCard = () => {
    Card.list().then(cards => {
        if (cards.length === 0) {
            Tag.findOne().exec()
                .then(tag => {
                    if (tag) {
                        debug("seeding card")
                        Card.create({
                            ...testCard,
                            tags: [tag._id]    
                        })
                    }
                    else {
                        debug("no tag found")
                    }
                })
        }
    })
}
{'fraction_non_alphanumeric': 0.1505773672055427, 'fraction_numerical': 0.0009237875288683603, 'mean_word_length': 1.277602523659306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6627145', 'n_tokens_mistral': 624, 'n_tokens_neox': 603, 'n_words': 126}