<commit_before>package publicshame

import grails.converters.JSON

class ApiSinEntryController {

    def createEntry() {
        def entry = new SinEntry(request.JSON)
        def group = Group.findWhere([lookup: params.groupId as String])

        if(!group.passphrase?.isEmpty() && request.JSON.passphrase != group.passphrase) {
            response.sendError(403)
            return
        }

        entry.group = group
        if(entry.save(failOnError: true)) {
            def resultMap = [
                    count: SinEntry.findWhere([group: group.id]).count()
            ]
            render resultMap as JSON
        } else {
            log.error(entry.errors)
            render entry.errors
        }
    }

    def getAllEntries() {
        def jsonResponse = []
        SinEntry.findAllWhere([ group: Group.findWhere([ lookup: params.groupId ]) ]).each {
            jsonResponse.add([
                    sinner: it.sinner,
                    sin: it.sin,
                    misc: it.misc
            ])
        }
        def resultMap = [
                count: jsonResponse.size(),
                sins: jsonResponse
        ]
        render resultMap as JSON<commit_msg>Removing the ID from the getter<commit_after>package publicshame

import grails.converters.JSON

class ApiSinEntryController {

    def createEntry() {
        def entry = new SinEntry(request.JSON)
        def group = Group.findWhere([lookup: params.groupId as String])

        if(!group.passphrase?.isEmpty() && request.JSON.passphrase != group.passphrase) {
            response.sendError(403)
            return
        }

        entry.group = group
        if(entry.save(failOnError: true)) {
            def resultMap = [
                    count: SinEntry.findWhere([group: group]).count()
            ]
            render resultMap as JSON
        } else {
            log.error(entry.errors)
            render entry.errors
        }
    }

    def getAllEntries() {
        def jsonResponse = []
        SinEntry.findAllWhere([ group: Group.findWhere([ lookup: params.groupId ]) ]).each {
            jsonResponse.add([
                    sinner: it.sinner,
                    sin: it.sin,
                    misc: it.misc
            ])
        }
        def resultMap = [
                count: jsonResponse.size(),
                sins: jsonResponse
        ]
        render resultMap as JSON
{'fraction_non_alphanumeric': 0.09680099709181554, 'fraction_numerical': 0.0024927295388450354, 'mean_word_length': 1.542766631467793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1371713', 'n_tokens_mistral': 652, 'n_tokens_neox': 619, 'n_words': 138}