<commit_before>package db

import (
	"github.com/dancannon/gorethink"
	"github.com/dolaterio/dolaterio/core"
)

// Connection represents a connection to the database
type Connection struct {
	s         *gorethink.Session
	db        gorethink.Term
	jobsTable gorethink.Term
}

// NewConnection initializes and returns a DB connection ready to use
func NewConnection() (*Connection, error) {
	// Open a session to the DB
	s, err := gorethink.Connect(gorethink.ConnectOpts{
		Address:  core.Config.RethinkDbAddress,
		Database: "dolaterio",
		MaxIdle:  10,
		MaxOpen:  10,
	})

	if err != nil {
		return nil, err
	}

	connection := &Connection{
		s: s,
	}

	s.SetMaxOpenConns(5)

	// Get the db (and create if missing)
	q, err := gorethink.DbList().Run(s)
	if err != nil {
		return nil, err
	}
<commit_msg>More hope<commit_after>package db

import (
	"github.com/dancannon/gorethink"
	"github.com/dolaterio/dolaterio/core"
)

// Connection represents a connection to the database
type Connection struct {
	s         *gorethink.Session
	db        gorethink.Term
	jobsTable gorethink.Term
}

// NewConnection initializes and returns a DB connection ready to use
func NewConnection() (*Connection, error) {
	// Open a session to the DB
	s, err := gorethink.Connect(gorethink.ConnectOpts{
		Address:  core.Config.RethinkDbAddress,
		Database: "dolaterio",
		MaxIdle:  10,
		MaxOpen:  10,
	})

	if err != nil {
		return nil, err
	}

	_, err = gorethink.Wait().Run(s)

	if err != nil {
		return nil, err
	}

	connection := &Connection{
		s: s,
	}

	s.SetMaxOpenConns(5)

	// Get the db (and create if missing)
	q, err := gorethink.DbList().Run(s)
	if err != nil {
		return nil, err
	}

{'fraction_non_alphanumeric': 0.11396181384248211, 'fraction_numerical': 0.0059665871121718375, 'mean_word_length': 3.3671875, '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': '3899195', 'n_tokens_mistral': 632, 'n_tokens_neox': 602, 'n_words': 167}