<commit_before>package edu.oregonstate.mist.tasx

class UserRestController {

    static responseFormats = ["json"]

    /**
     * Respond with all users serialized as JSON
     *
     * $ curl -X GET -H "Accept:application/json" /tasx/rest/user
     *
     * @return       JSON response
     */
    def index() {
        respond(User.findAll().collect(serializeUser))
    }

    /**
     * Respond with user serialized as JSON
     *
     * $ curl -X GET -H "Accept:application/json" /tasx/rest/user/ID
     *
     * @param user   from URL
     * @return       JSON response
     */
    def show(User user) {
        respond(serializeUser(user))
    }

    private Closure serializeUser = {
        user ->
            [ id:    user.id,
              name:  user.name,
              email: user.email,
              tasks: user.tasks ]
    }
}
<commit_msg>return empty JSON object if no such user<commit_after>package edu.oregonstate.mist.tasx

class UserRestController {

    static responseFormats = ["json"]

    /**
     * Respond with all users serialized as JSON
     *
     * $ curl -X GET -H "Accept:application/json" /tasx/rest/user
     *
     * @return       JSON response
     */
    def index() {
        respond(User.findAll().collect(serializeUser))
    }

    /**
     * Respond with user serialized as JSON
     *
     * $ curl -X GET -H "Accept:application/json" /tasx/rest/user/ID
     *
     * @param user   from URL
     * @return       JSON response
     */
    def show(User user) {
        if (user) {
            respond(serializeUser(user))
        } else {
            respond([])
        }
    }

    private Closure serializeUser = {
        user ->
            [ id:    user.id,
              name:  user.name,
              email: user.email,
              tasks: user.tasks ]
    }
}

{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.0, 'mean_word_length': 1.6135057471264367, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3111763', 'n_tokens_mistral': 558, 'n_tokens_neox': 541, 'n_words': 133}