diff --git a/src/database/main.go b/src/database/main.go index 4d5bc01..dd58a19 100644 --- a/src/database/main.go +++ b/src/database/main.go @@ -3,6 +3,7 @@ package database import ( "fmt" "log" + "time" "git.paulbsd.com/paulbsd/qrz/src/config" "git.paulbsd.com/paulbsd/qrz/src/qrz" @@ -29,9 +30,15 @@ func Initialize(config *config.Config) (err error) { config.DbHostname, config.DbName) } - config.Db, err = xorm.NewEngine(config.DbType, connstr) - if err != nil { - log.Fatalln(err) + + for { + log.Println("connecting to database") + config.Db, err = xorm.NewEngine(config.DbType, connstr) + if err != nil { + time.Sleep(1 * time.Second) + } else { + break + } } config.Db.SetMapper(names.GonicMapper{}) diff --git a/src/qrz/main.go b/src/qrz/main.go index d89153b..cb844e3 100644 --- a/src/qrz/main.go +++ b/src/qrz/main.go @@ -39,10 +39,9 @@ func Run(config config.Config) (err error) { for _, group := range groups { url := fmt.Sprintf(config.URLBase, group) - log.Println( - fmt.Sprintf("Processing the %s group with URL %s", - group, - url)) + log.Printf("Processing the %s group with URL %s", + group, + url) bodyStr, err := getBody(url) if err != nil { @@ -69,9 +68,8 @@ func Run(config config.Config) (err error) { continue } } else { - log.Println( - fmt.Sprintf("No entry to insert in database for group %s", - group)) + log.Printf("No entry to insert in database for group %s", + group) } } return @@ -89,8 +87,7 @@ func getGroups(urlbase string) (groups []string, err error) { } retstr := string(pagebody) - b := gre1.FindStringSubmatch(retstr) - body := b[1] + body := gre1.FindStringSubmatch(retstr)[1] htmlpage, err := htmlquery.Parse(strings.NewReader(body)) if err != nil { @@ -199,9 +196,8 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err var qrzNum int - log.Println( - fmt.Sprintf("Starting insert of %d entries", - len(frsPeople))) + log.Printf("Starting insert of %d entries", + len(frsPeople)) for _, frs := range frsPeople { _, err = session.Insert(&frs) @@ -221,7 +217,7 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err if err != nil { return err } - log.Println(fmt.Sprintf("Committed %d qrz entries", qrzNum)) + log.Printf("Committed %d qrz entries", qrzNum) return nil } diff --git a/static/js/functions.js b/static/js/functions.js index 71e4f3c..27bd3fe 100644 --- a/static/js/functions.js +++ b/static/js/functions.js @@ -1,3 +1,3 @@ function export_frs() { - var w = window.location.href = "/export_frs.csv"; + window.location.href = "/export_frs.csv"; }