This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2017-05-18 23:42:00 +02:00
|
|
|
// Package with supporting functionality to run the microservice
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/lib/database"
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/models"
|
|
|
|
)
|
|
|
|
|
2017-06-21 15:25:18 +02:00
|
|
|
// Function to automatically remove goods, if they are fouled
|
2017-05-18 23:42:00 +02:00
|
|
|
func GoodFouled() int {
|
|
|
|
var goods []*models.Good
|
|
|
|
var g models.Good
|
|
|
|
g.FilterAvailable(database.Read).Where("fouled_at <= ?", time.Now()).Find(&goods)
|
|
|
|
now := time.Now()
|
|
|
|
|
|
|
|
for _, good := range goods {
|
|
|
|
good.FouledDelete = true
|
|
|
|
good.DeletedAt = &now
|
|
|
|
database.Write.Save(&good)
|
|
|
|
}
|
|
|
|
return len(goods)
|
|
|
|
}
|