Fixed DB
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2019-09-02 22:33:11 +02:00
parent a95722c4d4
commit 14c99e0640
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 17 additions and 18 deletions

11
main.go
View File

@ -49,19 +49,18 @@ func main() {
# Version: ` + models.Version + ` #
################################################################`)
//DB init - Create tables
models.DBinit()
//Config
// Config
config.InitConfig()
//Echo init
// DB init - Create tables
models.DBinit()
// Echo init
e := router.NewEcho()
router.RegisterRoutes(e)
// Start server
go func() {
fmt.Println(config.GetConfig())
if err := e.Start(config.GetInterface()); err != nil {
e.Logger.Info("shutting down...")
}

View File

@ -1,11 +1,11 @@
package models
type Community struct {
ID int64 `xorm:"pk autoincr"`
Name string
KCoins int64
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"text"`
KCoins int64 `xorm:"bigint(11)"`
KonfiCount int64
KonfiCount int64 `xorm:"bigint(11)"`
CoinsQuota float64 `xorm:"-"`
}
@ -26,7 +26,7 @@ func ReadAllCommunities(orderbyname bool) (communities []*Community, err error)
orderby = "Name ASC"
}
err = x.Select(".*, (cast(KCoins AS FLOAT) / cast(KonfiCount AS FLOAT)) as CoinsQuota").
err = x.Select("*, (cast(k_coins AS FLOAT) / cast(konfi_count AS FLOAT)) as CoinsQuota").
OrderBy(orderby).
Find(&communities)
if err != nil {

View File

@ -14,7 +14,7 @@ func DBinit() {
var err error
x, err = xorm.NewEngine("sqlite3", config.GetDBFile())
if err != nil {
log.Error(err)
log.Fatal(err)
}
x.SetMapper(core.GonicMapper{})

View File

@ -1,10 +1,10 @@
package models
type Kofi struct {
ID int64 `xorm:"pk autoincr"`
Name string
Gemeinde string
KCoins int64
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"text"`
Gemeinde string `xorm:"text"`
KCoins int64 `xorm:"bigint(11)"`
}
func (k *Kofi) Add() (err error) {
@ -35,9 +35,9 @@ func (k *Kofi) Update(moreCoins int64) (err error) {
}
func ReadAllKofis(orderbyNames bool) (kofis []*Kofi, err error) {
var orderby = "KCoins DESC"
var orderby = "k_coins DESC"
if orderbyNames {
orderby = "Name ASC"
orderby = "name ASC"
}
err = x.OrderBy(orderby).Find(&kofis)
return