<commit_before>package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/mattn/go-sqlite3"
)

// Achievements DB Model
type Achievements struct {
	ID          int    `gorm:"AUTO_INCREMENT" form:"id" json:"id"`
	Achievement string `gorm:"not null" form:"achievement" json:"achievement"`
}

// PostAchievement Create an Achievement
func PostAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	var achievement Achievements
	c.Bind(&achievement)
	if IsInt(achievement.Achievement) {
		c.JSON(400, gin.H{"error": "No Numbers allowed"})
	} else if achievement.Achievement != "" {
		db.Create(&achievement)
		c.JSON(201, gin.H{"success": achievement})
	} else {
		c.JSON(422, gin.H{"error": "Fields are empty"})
	}
}

// GetAchievements Gets all achievements
func GetAchievements(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	var achievements []Achievements
	db.Find(&achievements)
	c.JSON(200, achievements)
}

// GetAchievement Gets an achievement
func GetAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		c.JSON(200, achievement)
	} else {
		c.JSON(404, gin.H{"error": "Achievement #" + id + " not found"})
	}
}

// UpdateAchievement updates an Achievements
func UpdateAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		var newAchievement Achievements
		c.Bind(&newAchievement)
		if newAchievement.Achievement != "" {
			result := Achievements{
				ID:          achievement.ID,
				Achievement: newAchievement.Achievement,
			}
			db.Save(&result)
			c.JSON(200, gin.H{"success": result})
		} else {
			c.JSON(422, gin.H{"error": "One or more of the fields are empty"})
		}

	} else {
		c.JSON(404, gin.H{"error": "Achievement not found"})
	}
}

// DeleteAchievement deletes an achievement
func DeleteAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		db.Delete(&achievement)
		c.Status(204)
	} else {
		c.JSON(404, gin.H{"error": "Achievement not found"})
	}
}

// OptionsAchievement allows DELETE, POST and PUT to come through
func OptionsAchievement(c *gin.Context) {
	c.Writer.Header().Set("Access-Control-Allow-Methods", "DELETE,POST, PUT")
	c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type")
	c.Next()
}
<commit_msg>updated error message<commit_after>package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/mattn/go-sqlite3"
)

// Achievements DB Model
type Achievements struct {
	ID          int    `gorm:"AUTO_INCREMENT" form:"id" json:"id"`
	Achievement string `gorm:"not null" form:"achievement" json:"achievement"`
}

// PostAchievement Create an Achievement
func PostAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	var achievement Achievements
	c.Bind(&achievement)
	if IsInt(achievement.Achievement) {
		c.JSON(400, gin.H{"error": "No Numbers allowed"})
	} else if achievement.Achievement != "" {
		db.Create(&achievement)
		c.JSON(201, gin.H{"success": achievement})
	} else {
		c.JSON(422, gin.H{"error": "Fields are empty"})
	}
}

// GetAchievements Gets all achievements
func GetAchievements(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	var achievements []Achievements
	db.Find(&achievements)
	c.JSON(200, achievements)
}

// GetAchievement Gets an achievement
func GetAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		c.JSON(200, achievement)
	} else {
		c.JSON(404, gin.H{"error": "Achievement #" + id + " not found"})
	}
}

// UpdateAchievement updates an Achievements
func UpdateAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		var newAchievement Achievements
		c.Bind(&newAchievement)
		if newAchievement.Achievement != "" {
			result := Achievements{
				ID:          achievement.ID,
				Achievement: newAchievement.Achievement,
			}
			db.Save(&result)
			c.JSON(200, gin.H{"success": result})
		} else {
			c.JSON(422, gin.H{"error": "The Achievement field is empty"})
		}

	} else {
		c.JSON(404, gin.H{"error": "Achievement not found"})
	}
}

// DeleteAchievement deletes an achievement
func DeleteAchievement(c *gin.Context) {
	db := InitDb()
	defer db.Close()

	id := c.Params.ByName("id")
	var achievement Achievements
	db.First(&achievement, id)

	if achievement.ID != 0 {
		db.Delete(&achievement)
		c.Status(204)
	} else {
		c.JSON(404, gin.H{"error": "Achievement not found"})
	}
}

// OptionsAchievement allows DELETE, POST and PUT to come through
func OptionsAchievement(c *gin.Context) {
	c.Writer.Header().Set("Access-Control-Allow-Methods", "DELETE,POST, PUT")
	c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type")
	c.Next()
}

{'fraction_non_alphanumeric': 0.15237351045126002, 'fraction_numerical': 0.014455948427427232, 'mean_word_length': 4.161290322580645, 'pattern_counts': {'":': 16, '<': 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': '3666071', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1856, 'n_words': 409}