<commit_before>package v1

import (
	"database/sql"
	"fmt"
	"os"

	"github.com/coopernurse/gorp"
	"github.com/hackedu/backend/v1/model"
	_ "github.com/lib/pq"
)

var Dbm *gorp.DbMap

func init() {
	Dbm = newDbMap()

	Dbm.AddTable(model.School{}).SetKeys(true, "Id")
	Dbm.AddTableWithName(model.User{}, "Users").SetKeys(true, "Id")
	Dbm.AddTable(model.Application{}).SetKeys(true, "Id")
}

func newDbMap() *gorp.DbMap {
	dialect, driver := dialectAndDriver()
	return &gorp.DbMap{Db: connect(driver), Dialect: dialect}
}

func dialectAndDriver() (gorp.Dialect, string) {
	return gorp.PostgresDialect{}, "postgres"
}

func connect(driver string) *sql.DB {
	dsn := fmt.Sprintf("postgres://docker:docker@%s/docker",
		os.Getenv("DB_1_PORT_5432_TCP_ADDR"))

	if os.Getenv("ENV") == "PRODUCTION" {
		dsn = os.Getenv("DATABASE_URL")
		if dsn == "" {
			panic("DATABASE_URL env variable not set")
		}
	}

	db, err := sql.Open(driver, dsn)
	if err != nil {
		panic("Error connecting to db: " + err.Error())
	}
	return db
}
<commit_msg>Read MARTINI_ENV instead of ENV.<commit_after>package v1

import (
	"database/sql"
	"fmt"
	"os"

	"github.com/codegangsta/martini"
	"github.com/coopernurse/gorp"
	"github.com/hackedu/backend/v1/model"
	_ "github.com/lib/pq"
)

var Dbm *gorp.DbMap

func init() {
	Dbm = newDbMap()

	Dbm.AddTable(model.School{}).SetKeys(true, "Id")
	Dbm.AddTableWithName(model.User{}, "Users").SetKeys(true, "Id")
	Dbm.AddTable(model.Application{}).SetKeys(true, "Id")
}

func newDbMap() *gorp.DbMap {
	dialect, driver := dialectAndDriver()
	return &gorp.DbMap{Db: connect(driver), Dialect: dialect}
}

func dialectAndDriver() (gorp.Dialect, string) {
	return gorp.PostgresDialect{}, "postgres"
}

func connect(driver string) *sql.DB {
	dsn := fmt.Sprintf("postgres://docker:docker@%s/docker",
		os.Getenv("DB_1_PORT_5432_TCP_ADDR"))

	if martini.Env == martini.Prod {
		dsn = os.Getenv("DATABASE_URL")
		if dsn == "" {
			panic("DATABASE_URL env variable not set")
		}
	}

	db, err := sql.Open(driver, dsn)
	if err != nil {
		panic("Error connecting to db: " + err.Error())
	}
	return db
}

{'fraction_non_alphanumeric': 0.17588179218303146, 'fraction_numerical': 0.00667302192564347, 'mean_word_length': 4.612299465240642, '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': '6216926', 'n_tokens_mistral': 904, 'n_tokens_neox': 862, 'n_words': 153}