<commit_before>package main

import (
	"database/sql"
	"flag"

	"github.com/gin-gonic/contrib/static"
	"github.com/gin-gonic/gin"
	"gopkg.in/gorp.v1"

	"github.com/danjac/kanban/api"
	"github.com/danjac/kanban/db"
	"github.com/danjac/kanban/models"
	_ "github.com/mattn/go-sqlite3"
)

func initDB(dbName string) *gorp.DbMap {
	db, err := sql.Open("sqlite3", dbName)
	if err != nil {
		panic(err)
	}
	dbMap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
	dbMap.AddTableWithName(models.TaskList{}, "tasklists").SetKeys(true, "id")
	dbMap.AddTableWithName(models.Task{}, "tasks").SetKeys(true, "id")
	if err = dbMap.CreateTablesIfNotExists(); err != nil {
		panic(err)
	}
	return dbMap
}

var dbName = flag.String("db", "/tmp/kanban.sqlite", "sqlite database filename")

func main() {

	flag.Parse()

	dbMap := initDB(*dbName)

	dataManager := db.NewDataManager(dbMap)

	r := gin.Default()

	r.Use(static.Serve("/", static.LocalFile("static", false)))

	api.New(r, "/api/v1", dataManager)

	r.Run(":8080")
}<commit_msg>Some api refactoring<commit_after>package main

import (
	"database/sql"
	"flag"

	"github.com/gin-gonic/contrib/static"
	"github.com/gin-gonic/gin"
	"gopkg.in/gorp.v1"

	"github.com/danjac/kanban/api"
	"github.com/danjac/kanban/db"
	"github.com/danjac/kanban/models"
	_ "github.com/mattn/go-sqlite3"
)

func initDB(dbName string) *gorp.DbMap {
	db, err := sql.Open("sqlite3", dbName)
	if err != nil {
		panic(err)
	}
	dbMap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
	dbMap.AddTableWithName(models.TaskList{}, "tasklists").SetKeys(true, "id")
	dbMap.AddTableWithName(models.Task{}, "tasks").SetKeys(true, "id")
	if err = dbMap.CreateTablesIfNotExists(); err != nil {
		panic(err)
	}
	return dbMap
}

var dbName = flag.String("db", "/tmp/kanban.sqlite", "sqlite database filename")

func main() {

	flag.Parse()

	r := gin.Default()

	r.Use(static.Serve("/", static.LocalFile("static", false)))

	api.New(r, "/api/v1", db.NewDataManager(initDb(*dbName)))

	r.Run(":8080")
}
{'fraction_non_alphanumeric': 0.19133034379671152, 'fraction_numerical': 0.007972097658196313, 'mean_word_length': 4.624649859943977, 'pattern_counts': {'":': 2, '<': 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': '3124723', 'n_tokens_mistral': 869, 'n_tokens_neox': 833, 'n_words': 130}