<commit_before>package main

import (
	"sort"

	"github.com/animenotifier/arn"
	"github.com/fatih/color"
)

// Note this is using the airing-anime as a template with modfications
// made to it.
func main() {
	color.Yellow("Caching popular anime")

	animeChan, err := arn.AllAnime()

	if err != nil {
		color.Red("Failed fetching anime channel")
		color.Red(err.Error())
		return
	}

	var animeList []*arn.Anime

	for anime := range animeChan {
		animeList = append(animeList, anime)
	}

	sort.Slice(animeList, func(i, j int) bool {
		return animeList[i].Rating.Overall > animeList[j].Rating.Overall
	})
	// Change size of anime list to 10
	animeList = animeList[:10]

	// Convert to small anime list
	cache := &arn.ListOfIDs{}

	for _, anime := range animeList {
		cache.IDList = append(cache.IDList, anime.ID)
	}

	println(len(cache.IDList))

	saveErr := arn.DB.Set("Cache", "popular anime", cache)

	if saveErr != nil {
		color.Red("Error saving popular anime")
		color.Red(saveErr.Error())
		return
	}

	color.Green("Finished.")
}<commit_msg>changes made<commit_after>package main

import (
	"sort"

	"github.com/animenotifier/arn"
	"github.com/fatih/color"
)


const maxPopularAnime = 10

// Note this is using the airing-anime as a template with modfications
// made to it.
func main() {
	color.Yellow("Caching popular anime")

	animeChan, err := arn.AllAnime()

	if err != nil {
		color.Red("Failed fetching anime channel")
		color.Red(err.Error())
		return
	}

	var animeList []*arn.Anime

	for anime := range animeChan {
		animeList = append(animeList, anime)
	}

	sort.Slice(animeList, func(i, j int) bool {
		return animeList[i].Rating.Overall > animeList[j].Rating.Overall
	})
	
	// Change size of anime list to 10
	animeList = animeList[:maxPopularAnime]

	// Convert to small anime list
	cache := &arn.ListOfIDs{}

	for _, anime := range animeList {
		cache.IDList = append(cache.IDList, anime.ID)
	}

	println(len(cache.IDList))

	saveErr := arn.DB.Set("Cache", "popular anime", cache)

	if saveErr != nil {
		color.Red("Error saving popular anime")
		color.Red(saveErr.Error())
		return
	}

	color.Green("Finished.")
}
{'fraction_non_alphanumeric': 0.13830285982184717, 'fraction_numerical': 0.003750586029067042, 'mean_word_length': 3.8063063063063063, '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': '5364918', 'n_tokens_mistral': 820, 'n_tokens_neox': 750, 'n_words': 192}