<commit_before>package store

import (
	"fmt"

	"github.com/gempir/bitraft/pkg/config"
	"github.com/gempir/bitraft/pkg/log"
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

type Database struct {
	Client *gorm.DB
}

func NewDatabase(cfg *config.Config) *Database {
	dsn := fmt.Sprintf("host=localhost user=%s password=%s dbname=bitraft port=5432 sslmode=disable TimeZone=Europe/Berlin", cfg.PostgresUsername, cfg.PostgresPassword)
	pdb, err := gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: log.NewGormLogger()})
	if err != nil {
		panic("failed to connect postgres database")
	}

	// Migrate the schema
	err = pdb.AutoMigrate(&ChannelPointReward{}, &EventSubSubscription{}, &UserAccessToken{}, &EmoteAdd{}, &PredictionLog{}, &PredictionLogOutcome{}, &BotConfig{}, &Permission{})
	if err != nil {
		panic(err)
	}

	return &Database{
		Client: pdb,
	}
}<commit_msg>more logging<commit_after>package store

import (
	"fmt"

	"github.com/gempir/bitraft/pkg/config"
	"github.com/gempir/bitraft/pkg/log"
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

type Database struct {
	Client *gorm.DB
}

func NewDatabase(cfg *config.Config) *Database {
	dsn := fmt.Sprintf("host=localhost user=%s password=%s dbname=bitraft port=5432 sslmode=disable TimeZone=Europe/Berlin", cfg.PostgresUsername, cfg.PostgresPassword)
	pdb, err := gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: log.NewGormLogger()})
	if err != nil {
		panic("failed to connect postgres database")
	}
	log.Info("connected postgres on localhost:5432")

	// Migrate the schema
	err = pdb.AutoMigrate(&ChannelPointReward{}, &EventSubSubscription{}, &UserAccessToken{}, &EmoteAdd{}, &PredictionLog{}, &PredictionLogOutcome{}, &BotConfig{}, &Permission{})
	if err != nil {
		panic(err)
	}

	return &Database{
		Client: pdb,
	}
}
{'fraction_non_alphanumeric': 0.15626756604834177, 'fraction_numerical': 0.006745362563237774, 'mean_word_length': 5.544117647058823, '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': '6398874', 'n_tokens_mistral': 664, 'n_tokens_neox': 639, 'n_words': 125}