<commit_before>/*
 * WordGridController.java
 *
 * Copyright (C) 2017 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

package com.aleggeup.confagrid.controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aleggeup.confagrid.data.WordGridRepository;
import com.aleggeup.confagrid.model.WordGrid;

@Controller
@RequestMapping("/api/v1")
public class WordGridController {

    private final WordGridRepository wordGridRepository;

    @Autowired
    public WordGridController(final WordGridRepository wordGridRepository) {
        this.wordGridRepository = wordGridRepository;
    }

    @RequestMapping("word-grids")
    @ResponseBody
    public List<WordGrid> allWordGrids() {
        final List<WordGrid> wordGrids = new ArrayList<>();

        for (final Iterator<WordGrid> iterator = this.wordGridRepository.findAll().iterator(); iterator.hasNext();) {
            wordGrids.add(iterator.next());
        }

        return wordGrids;
    }
}<commit_msg>Add a 'create' to save to database<commit_after>/*
 * WordGridController.java
 *
 * Copyright (C) 2017 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

package com.aleggeup.confagrid.controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aleggeup.confagrid.data.WordGridRepository;
import com.aleggeup.confagrid.model.WordGrid;

@Controller
@RequestMapping("/api/v1")
public class WordGridController {

    private final WordGridRepository wordGridRepository;

    @Autowired
    public WordGridController(final WordGridRepository wordGridRepository) {
        this.wordGridRepository = wordGridRepository;
    }

    @RequestMapping("word-grids")
    @ResponseBody
    public List<WordGrid> allWordGrids() {
        final List<WordGrid> wordGrids = new ArrayList<>();

        for (final Iterator<WordGrid> iterator = this.wordGridRepository.findAll().iterator(); iterator.hasNext();) {
            wordGrids.add(iterator.next());
        }

        return wordGrids;
    }

    @RequestMapping(method = RequestMethod.POST, value="/word-grids")
    @ResponseBody
    public List<WordGrid> create(@RequestBody WordGrid wordGrid) {
        final List<WordGrid> wordGrids = new ArrayList<>();
        final WordGrid savedWordGrid = this.wordGridRepository.save(wordGrid);
        wordGrids.add(savedWordGrid);

        return wordGrids;
    }
}
{'fraction_non_alphanumeric': 0.09921507064364207, 'fraction_numerical': 0.0031397174254317113, 'mean_word_length': 4.214402618657938, 'pattern_counts': {'":': 0, '<': 14, '<?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': '3442144', 'n_tokens_mistral': 895, 'n_tokens_neox': 881, 'n_words': 197}