<commit_before>package main

import "errors"
import "time"
import "github.com/naoina/genmai"

// "create table if not exists news (text varchar(256), unixTime int, index uti(unixTime))"
// News contains news showed on "/"
type News struct {
    Text string `default:""`
    UnixTime time.Time `default:"" size:"1024"`
}

func (dm * DatabaseManager) CreateNewsTable() error {
    err := dm.db.CreateTableIfNotExists(&News{})

    if err != nil {
        return err
    }

    dm.db.CreateIndex(&News{}, "unixTime")

    return nil
}

// AddNews adds a news displayed on "/"
// len(text) <= 256
func (dm *DatabaseManager) AddNews(text string) error {
    if len(text) > 256 {
        return errors.New("len(text) > 256")
    }
    
    
    _, err := dm.db.Insert(&News{text, time.Now()})

    //_, err := dm.db.Exec("insert into news (text, unixTime) values(?, unix_timestamp(now()))", text)
    
    return err
}

// AddNewsWithTime adds a news displayed on "/" with unixtime
// len(text) <= 256
func (dm *DatabaseManager) AddNewsWithTime(text string, unixTime time.Time) error {
    if len(text) > 256 {
        return errors.New("len(text) > 256")
    }
    
    _, err := dm.db.Insert(&News{text, unixTime})
    
    return err
}

// GetNews returns `showedNewCount` recent news of 
func (dm *DatabaseManager) NewsGet() ([]News, error) {
    var resulsts []News
    err := dm.db.Select(&resulsts, dm.db.OrderBy("unix_time", genmai.DESC).Limit(dm.showedNewCount))
    
    if err != nil {
        return nil, err
    }

    return resulsts, nil
}<commit_msg>Fix NewsAdd and NewsGet<commit_after>package main

import "errors"
import "time"
import "github.com/naoina/genmai"

// "create table if not exists news (text varchar(256), unixTime int, index uti(unixTime))"
// News contains news showed on "/"
type News struct {
	Text     string    `default:""`
	UnixTime time.Time `default:"" size:"1024"`
}

func (dm *DatabaseManager) CreateNewsTable() error {
	err := dm.db.CreateTableIfNotExists(&News{})

	if err != nil {
		return err
	}

	dm.db.CreateIndex(&News{}, "unixTime")

	return nil
}

// AddNews adds a news displayed on "/"
// len(text) <= 256
func (dm *DatabaseManager) NewsAdd(text string) error {
	if len(text) > 256 {
		return errors.New("len(text) > 256")
	}

	_, err := dm.db.Insert(&News{text, time.Now()})

	//_, err := dm.db.Exec("insert into news (text, unixTime) values(?, unix_timestamp(now()))", text)

	return err
}

// AddNewsWithTime adds a news displayed on "/" with unixtime
// len(text) <= 256
func (dm *DatabaseManager) NewsAddWithTime(text string, unixTime time.Time) error {
	if len(text) > 256 {
		return errors.New("len(text) > 256")
	}

	_, err := dm.db.Insert(&News{text, unixTime})

	return err
}

// GetNews returns `showedNewCount` recent news of
func (dm *DatabaseManager) NewsGet() ([]News, error) {
	var resulsts []News
	err := dm.db.Select(&resulsts, dm.db.OrderBy("unix_time", genmai.DESC).Limit(dm.showedNewCount))

	if err != nil {
		return nil, err
	}

	return resulsts, nil
}
{'fraction_non_alphanumeric': 0.15282831624214357, 'fraction_numerical': 0.016539861065167052, 'mean_word_length': 3.4933135215453195, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5942890', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1035, 'n_words': 287}