genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
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.
hs_monolith/runtime/good_fouled.go

25 lines
582 B
Go

// 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"
)
// Function to remove automaticle goods after the are fouled
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)
}