pull/10/head
Hunter Long 2018-06-28 21:21:10 -07:00
parent e4eb5370f0
commit e7771844b1
4 changed files with 11 additions and 6 deletions

View File

@ -51,7 +51,6 @@ notifications:
email: false
before_install:
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
before_script:
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
@ -71,6 +70,7 @@ script:
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
after_success:
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then /bin/bash -c .travis/build.sh; fi
after_deploy:

View File

@ -8,6 +8,7 @@ import (
"upper.io/db.v3/mysql"
"upper.io/db.v3/postgresql"
"upper.io/db.v3/sqlite"
"github.com/hunterlong/statup/log"
)
var (
@ -26,6 +27,7 @@ func DbConnection(dbType string) error {
}
dbSession, err = sqlite.Open(sqliteSettings)
if err != nil {
log.Send(3, err)
return err
}
} else if dbType == "mysql" {
@ -40,6 +42,7 @@ func DbConnection(dbType string) error {
}
dbSession, err = mysql.Open(mysqlSettings)
if err != nil {
log.Send(3, err)
return err
}
} else {
@ -55,6 +58,7 @@ func DbConnection(dbType string) error {
}
dbSession, err = postgresql.Open(postgresSettings)
if err != nil {
log.Send(3, err)
return err
}
}
@ -76,7 +80,7 @@ func DeleteAllSince(table string, date time.Time) {
sql := fmt.Sprintf("DELETE FROM %v WHERE created_at < '%v';", table, date.Format("2006-01-02"))
_, err := dbSession.Exec(db.Raw(sql))
if err != nil {
fmt.Println(err)
log.Send(2, err)
}
}

View File

@ -36,8 +36,9 @@ func EmailerQueue() {
uniques := []*types.Email{}
for _, out := range emailQue.Outgoing {
if isUnique(uniques, out) {
fmt.Printf("sending email to: %v \n", out.To)
msg := fmt.Sprintf("sending email to: %v \n", out.To)
Send(out)
log.Send(0, msg)
uniques = append(uniques, out)
}
}
@ -65,7 +66,6 @@ func Send(em *types.Email) {
m.SetBody("text/html", source)
if err := emailQue.Mailer.DialAndSend(m); err != nil {
log.Send(2, err)
fmt.Println(err)
}
emailQue.LastSent++
emailQue.LastSentTime = time.Now()
@ -95,12 +95,12 @@ func LoadMailer(config *types.Communication) *gomail.Dialer {
func EmailTemplate(tmpl string, data interface{}) string {
emailTpl, err := emailBox.String(tmpl)
if err != nil {
panic(err)
log.Send(3, err)
}
t := template.New("email")
t, err = t.Parse(emailTpl)
if err != nil {
panic(err)
log.Send(3, err)
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, data); err != nil {

View File

@ -34,6 +34,7 @@ func init() {
}
func Panic(err interface{}) {
lg.Printf("PANIC: %v\n", err)
panic(err)
}