misc fixes
This commit is contained in:
parent
b24c4cb5da
commit
e7166cab1b
@ -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)
|
||||
}
|
||||
|
||||
for {
|
||||
log.Println("connecting to database")
|
||||
config.Db, err = xorm.NewEngine(config.DbType, connstr)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
time.Sleep(1 * time.Second)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
config.Db.SetMapper(names.GonicMapper{})
|
||||
|
@ -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",
|
||||
log.Printf("Processing the %s group with URL %s",
|
||||
group,
|
||||
url))
|
||||
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
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
function export_frs() {
|
||||
var w = window.location.href = "/export_frs.csv";
|
||||
window.location.href = "/export_frs.csv";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user