update
All checks were successful
Build and Publish / Metadata (push) Successful in 9s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m13s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m26s

This commit is contained in:
matst80
2025-10-16 18:01:32 +02:00
parent 15089862d5
commit c060680768
8 changed files with 263 additions and 181 deletions

View File

@@ -13,7 +13,6 @@ import (
"sort"
"strconv"
"strings"
"syscall"
"time"
"git.tornberg.me/go-cart-actor/pkg/actor"
@@ -54,27 +53,27 @@ func isValidFileId(name string) (uint64, bool) {
return 0, false
}
func AccessTime(info os.FileInfo) (time.Time, bool) {
switch stat := info.Sys().(type) {
case *syscall.Stat_t:
// Linux: Atim; macOS/BSD: Atimespec
// Use reflection or build tags if naming differs.
// Linux:
if stat.Atim.Sec != 0 || stat.Atim.Nsec != 0 {
return time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)), true
}
// macOS/BSD example (uncomment if needed):
// return time.Unix(int64(stat.Atimespec.Sec), int64(stat.Atimespec.Nsec)), true
}
return time.Time{}, false
}
// func AccessTime(info os.FileInfo) (time.Time, bool) {
// switch stat := info.Sys().(type) {
// case *syscall.Stat_t:
// // Linux: Atim; macOS/BSD: Atimespec
// // Use reflection or build tags if naming differs.
// // Linux:
// if stat.Atim.Sec != 0 || stat.Atim.Nsec != 0 {
// return time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)), true
// }
// // macOS/BSD example (uncomment if needed):
// //return time.Unix(int64(stat.Atimespec.Sec), int64(stat.Atimespec.Nsec)), true
// }
// return time.Time{}, false
// }
func appendFileInfo(info fs.FileInfo, out *CartFileInfo) *CartFileInfo {
sys := info.Sys()
fmt.Printf("sys type %T", sys)
out.Size = info.Size()
out.Modified = info.ModTime()
out.Accessed, _ = AccessTime(info)
//out.Accessed, _ = AccessTime(info)
return out
}

View File

@@ -19,7 +19,6 @@ type CartFileInfo struct {
CartId cart.CartId `json:"cartId"`
Size int64 `json:"size"`
Modified time.Time `json:"modified"`
Accessed time.Time `json:"accessed"`
}
func envOrDefault(key, def string) string {

View File

@@ -43,31 +43,41 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
if err != nil {
return nil, err
}
return ToItemAddMessage(item, storeId, qty, country), nil
return ToItemAddMessage(item, storeId, qty, country)
}
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) *messages.AddItem {
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) (*messages.AddItem, error) {
orgPrice, _ := getInt(item.GetNumberFieldValue(5)) // getInt(item.Fields[5])
price, err := getInt(item.GetNumberFieldValue(4)) //Fields[4]
if err != nil {
return nil
return nil, err
}
stock := cart.StockStatus(0)
centralStockValue, ok := item.GetStringFieldValue(3)
if storeId == nil {
if ok {
if !item.Buyable {
return nil, fmt.Errorf("item not available")
}
pureNumber := strings.Replace(centralStockValue, "+", "", -1)
if centralStock, err := strconv.ParseInt(pureNumber, 10, 64); err == nil {
stock = cart.StockStatus(centralStock)
}
if stock == cart.StockStatus(0) && item.SaleStatus == "TBD" {
return nil, fmt.Errorf("no items available")
}
}
} else {
if !item.BuyableInStore {
return nil, fmt.Errorf("item not available in store")
}
storeStock, ok := item.Stock.GetStock()[*storeId]
if ok {
stock = cart.StockStatus(storeStock)
}
}
articleType, _ := item.GetStringFieldValue(1) //.Fields[1].(string)
@@ -109,7 +119,8 @@ func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country st
Country: country,
Outlet: outlet,
StoreId: storeId,
}
SaleStatus: item.SaleStatus,
}, nil
}
func getTax(articleType string) int32 {