misc fixes
This commit is contained in:
parent
b24c4cb5da
commit
e7166cab1b
@ -3,6 +3,7 @@ package database
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.paulbsd.com/paulbsd/qrz/src/config"
|
"git.paulbsd.com/paulbsd/qrz/src/config"
|
||||||
"git.paulbsd.com/paulbsd/qrz/src/qrz"
|
"git.paulbsd.com/paulbsd/qrz/src/qrz"
|
||||||
@ -29,9 +30,15 @@ func Initialize(config *config.Config) (err error) {
|
|||||||
config.DbHostname,
|
config.DbHostname,
|
||||||
config.DbName)
|
config.DbName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
log.Println("connecting to database")
|
||||||
config.Db, err = xorm.NewEngine(config.DbType, connstr)
|
config.Db, err = xorm.NewEngine(config.DbType, connstr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
time.Sleep(1 * time.Second)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Db.SetMapper(names.GonicMapper{})
|
config.Db.SetMapper(names.GonicMapper{})
|
||||||
|
@ -39,10 +39,9 @@ func Run(config config.Config) (err error) {
|
|||||||
|
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
url := fmt.Sprintf(config.URLBase, group)
|
url := fmt.Sprintf(config.URLBase, group)
|
||||||
log.Println(
|
log.Printf("Processing the %s group with URL %s",
|
||||||
fmt.Sprintf("Processing the %s group with URL %s",
|
|
||||||
group,
|
group,
|
||||||
url))
|
url)
|
||||||
|
|
||||||
bodyStr, err := getBody(url)
|
bodyStr, err := getBody(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,9 +68,8 @@ func Run(config config.Config) (err error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Println(
|
log.Printf("No entry to insert in database for group %s",
|
||||||
fmt.Sprintf("No entry to insert in database for group %s",
|
group)
|
||||||
group))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -89,8 +87,7 @@ func getGroups(urlbase string) (groups []string, err error) {
|
|||||||
}
|
}
|
||||||
retstr := string(pagebody)
|
retstr := string(pagebody)
|
||||||
|
|
||||||
b := gre1.FindStringSubmatch(retstr)
|
body := gre1.FindStringSubmatch(retstr)[1]
|
||||||
body := b[1]
|
|
||||||
|
|
||||||
htmlpage, err := htmlquery.Parse(strings.NewReader(body))
|
htmlpage, err := htmlquery.Parse(strings.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -199,9 +196,8 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err
|
|||||||
|
|
||||||
var qrzNum int
|
var qrzNum int
|
||||||
|
|
||||||
log.Println(
|
log.Printf("Starting insert of %d entries",
|
||||||
fmt.Sprintf("Starting insert of %d entries",
|
len(frsPeople))
|
||||||
len(frsPeople)))
|
|
||||||
|
|
||||||
for _, frs := range frsPeople {
|
for _, frs := range frsPeople {
|
||||||
_, err = session.Insert(&frs)
|
_, err = session.Insert(&frs)
|
||||||
@ -221,7 +217,7 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Println(fmt.Sprintf("Committed %d qrz entries", qrzNum))
|
log.Printf("Committed %d qrz entries", qrzNum)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
function export_frs() {
|
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