minor changes on code
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2020-12-05 18:36:39 +01:00
parent d6a47080ac
commit 48e1aeb067
3 changed files with 21 additions and 5 deletions

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}