fix: add migration for newly introduced has data field

This commit is contained in:
Ferdinand Mütsch 2021-02-13 13:04:47 +01:00
parent 30510591eb
commit e2f046a83d
2 changed files with 23 additions and 10 deletions

View File

@ -0,0 +1,20 @@
package migrations
import (
"github.com/muety/wakapi/config"
"gorm.io/gorm"
)
func init() {
f := migrationFunc{
name: "20210213_add_has_data_field",
f: func(db *gorm.DB, cfg *config.Config) error {
if err := db.Exec("UPDATE users SET has_data = TRUE WHERE 1").Error; err != nil {
return err
}
return nil
},
}
registerPostMigration(f)
}

View File

@ -50,16 +50,9 @@ String.prototype.toHHMMSS = function () {
}
String.prototype.toHHMM = function () {
var sec_num = parseInt(this, 10)
var hours = Math.floor(sec_num / 3600)
var minutes = Math.floor((sec_num - (hours * 3600)) / 60)
if (hours < 10 && hours > 0) {
hours = '0' + hours
}
if (minutes < 10 && minutes > 0) {
minutes = '0' + minutes
}
const sec_num = parseInt(this, 10)
const hours = Math.floor(sec_num / 3600)
const minutes = Math.floor((sec_num - (hours * 3600)) / 60)
return hours + ':' + minutes
}