<commit_before>package main

import (
	"github.com/kataras/iris"
	log "github.com/Sirupsen/logrus"
	"gopkg.in/mgo.v2"
)

type AppsAPI struct {
	*iris.Context
	proxyRegister *ProxyRegister
}

// GET /apps
func (u AppsAPI) Get() {
	repo := u.getRepository()
	data, err := repo.FindAll()

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	u.JSON(iris.StatusOK, data)
}

// GET /apps/:param1 which its value passed to the id argument
func (u AppsAPI) GetBy(id string) {
	repo := u.getRepository()
	data, err := repo.FindByID(id)

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	u.JSON(iris.StatusOK, data)
}

// PUT /apps/:id
func (u AppsAPI) PutBy(id string) {
	repo := u.getRepository()
	apiSpec, err := repo.FindByID(id)

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	err = u.ReadJSON(apiSpec)

	if err != nil {
		log.Errorf("Error when reading json: %s", err.Error())
	}

	repo.Add(&apiSpec)
<commit_msg>Fixed saving operation<commit_after>package main

import (
	"github.com/kataras/iris"
	log "github.com/Sirupsen/logrus"
	"gopkg.in/mgo.v2"
)

type AppsAPI struct {
	*iris.Context
	proxyRegister *ProxyRegister
}

// GET /apps
func (u AppsAPI) Get() {
	repo := u.getRepository()
	data, err := repo.FindAll()

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	u.JSON(iris.StatusOK, data)
}

// GET /apps/:param1 which its value passed to the id argument
func (u AppsAPI) GetBy(id string) {
	repo := u.getRepository()
	data, err := repo.FindByID(id)

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	u.JSON(iris.StatusOK, data)
}

// PUT /apps/:id
func (u AppsAPI) PutBy(id string) {
	repo := u.getRepository()
	apiSpec, err := repo.FindByID(id)

	if err != nil {
		log.Errorf(err.Error())
		u.JSON(iris.StatusInternalServerError, err.Error())
	}

	err = u.ReadJSON(&apiSpec)

	if err != nil {
		log.Errorf("Error when reading json: %s", err.Error())
	}

	repo.Add(&apiSpec)

{'fraction_non_alphanumeric': 0.1638655462184874, 'fraction_numerical': 0.0018674136321195146, 'mean_word_length': 3.8157303370786515, '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': '3068728', 'n_tokens_mistral': 873, 'n_tokens_neox': 838, 'n_words': 182}