Fixed DB
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
a95722c4d4
commit
14c99e0640
11
main.go
11
main.go
|
@ -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...")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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{})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue