This commit is contained in:
parent
d6a47080ac
commit
48e1aeb067
@ -13,7 +13,12 @@ import (
|
||||
|
||||
// Initialize creates connection to database and exec Schema
|
||||
func Initialize(config *config.Config) (err error) {
|
||||
config.Db, err = xorm.NewEngine("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s", config.DbUsername, config.DbPassword, config.DbHostname, config.DbName))
|
||||
config.Db, err = xorm.NewEngine("postgres",
|
||||
fmt.Sprintf("postgres://%s:%s@%s/%s",
|
||||
config.DbUsername,
|
||||
config.DbPassword,
|
||||
config.DbHostname,
|
||||
config.DbName))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
@ -53,7 +53,9 @@ func Run(config config.Config) (err error) {
|
||||
log.Println(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf("No entry to insert in database for group %s", group))
|
||||
fmt.Println(
|
||||
fmt.Sprintf("No entry to insert in database for group %s",
|
||||
group))
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -144,7 +146,9 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err
|
||||
|
||||
var qrzNum int
|
||||
|
||||
fmt.Println(fmt.Sprintf("Starting insert of %d entries", len(frsPeople)))
|
||||
fmt.Println(
|
||||
fmt.Sprintf("Starting insert of %d entries",
|
||||
len(frsPeople)))
|
||||
|
||||
for _, frs := range frsPeople {
|
||||
_, err = session.Insert(&frs)
|
||||
@ -179,7 +183,13 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err
|
||||
|
||||
// ToSlice converts struct to array
|
||||
func ToSlice(qrz Qrz) (out []string) {
|
||||
out = []string{qrz.QRZ, qrz.Name, qrz.City, qrz.Dept, qrz.Country, qrz.DMRID}
|
||||
out = []string{
|
||||
qrz.QRZ,
|
||||
qrz.Name,
|
||||
qrz.City,
|
||||
qrz.Dept,
|
||||
qrz.Country,
|
||||
qrz.DMRID}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,8 @@ func BuildQueryCountFiltered(config config.Config, qrzdt QrzDatatableInput) (cnt
|
||||
|
||||
// BuildQueryCountTotal builds query for counting totals
|
||||
func BuildQueryCountTotal(config config.Config, qrzdt QrzDatatableInput) (cnt int64, err error) {
|
||||
cnt, err = config.Db.SQL("SELECT COUNT(*) FROM qrz").Count()
|
||||
var qrz qrz.Qrz
|
||||
cnt, err = config.Db.Count(&qrz)
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user