<commit_before>package komorebi

import (
	"log"
	"time"
)

type Column struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	Position  int    `json:"position"`
	BoardId   int    `json:"boardId"`
	CreatedAt int64  `json:"created_at"`
}

type Columns []Column

func NewColumn(name string, position int, boardId int) Column {
	return Column{
		CreatedAt: time.Now().UnixNano(),
		Name:      name,
		Position:  position,
		BoardId:   boardId,
	}
}

func (c Column) Save() bool {
	if c.Id == 0 {
		if errInsert := dbMapper.Connection.Insert(&c); errInsert != nil {
			log.Fatalln("save of column failed", errInsert)
			return false
		}
	} else {
		if _, errUpdate := dbMapper.Connection.Update(&c); errUpdate != nil {<commit_msg>fix reorder columns<commit_after>package komorebi

import (
	"log"
	"time"
)

type Column struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	Position  int    `json:"position"`
	BoardId   int    `json:"boardId"`
	CreatedAt int64  `json:"created_at"`
}

type Columns []Column

func NewColumn(name string, position int, boardId int) Column {
	return Column{
		CreatedAt: time.Now().UnixNano(),
		Name:      name,
		Position:  position,
		BoardId:   boardId,
	}
}

func (c Column) Save() bool {
	if c.Id == 0 {
		if c.Position == 0 {
			var max_pos int
			_, err := dbMapper.Connection.Select(&max_pos,
				"select Position from columns where BoardId=? order by Position Desc limit 1", c.BoardId)
			if err == nil {
				c.Position = max_pos + 1
			}
		}
		if errInsert := dbMapper.Connection.Insert(&c); errInsert != nil {
			log.Fatalln("save of column failed", errInsert)
			return false
		}
	} else {
		if _, errUpdate := dbMapper.Connection.Update(&c); errUpdate != nil {
{'fraction_non_alphanumeric': 0.1319884726224784, 'fraction_numerical': 0.005187319884726225, 'mean_word_length': 3.3291770573566084, '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': '4201959', 'n_tokens_mistral': 641, 'n_tokens_neox': 596, 'n_words': 169}