added published at and telegram notify for missing url

main
alex 2024-06-04 23:01:23 +02:00
parent f6f9d9dc09
commit 5dd7070807
3 changed files with 17 additions and 0 deletions

BIN
main

Binary file not shown.

View File

@ -13,6 +13,7 @@ type NewProduct struct {
Url string Url string
Variant string Variant string
Characteristics string Characteristics string
PublishedAt string
} }
type InWorkProduct struct { type InWorkProduct struct {

View File

@ -5,8 +5,10 @@ import (
"errors" "errors"
"fmt" "fmt"
"jannex/admin-dashboard-backend/modules/cache" "jannex/admin-dashboard-backend/modules/cache"
"jannex/admin-dashboard-backend/modules/config"
"jannex/admin-dashboard-backend/modules/database" "jannex/admin-dashboard-backend/modules/database"
"jannex/admin-dashboard-backend/modules/logger" "jannex/admin-dashboard-backend/modules/logger"
"jannex/admin-dashboard-backend/modules/notification"
"jannex/admin-dashboard-backend/modules/structs" "jannex/admin-dashboard-backend/modules/structs"
"strconv" "strconv"
@ -171,9 +173,22 @@ func fetchProducts(srv *sheets.Service) error {
}) })
} else if state == 3 { } else if state == 3 {
var url string var url string
var publishedAt string
if len(row) > 8 && row[8] != "" { if len(row) > 8 && row[8] != "" {
url = fmt.Sprintf("%v", row[8]) url = fmt.Sprintf("%v", row[8])
} else {
logger.AddSystemLog(rslogger.LogTypeWarning, "Url missing for product id: %s name: %s", productId, name)
notification.AddNotification(nil, structs.AddNotificationRequest{
UserIds: config.Cfg.NotificationUserIds,
Type: 3,
Title: "Missing 'Shop Produkt Link' for product pipeline\n\nproduct id: " + productId + "\nname: " + name + "\n\nDie URL für das Produkt in dem Google Sheet 'Produkte' -> Worksheet: 'Pipeline' eintragen!",
})
}
if len(row) > 9 && row[9] != "" {
publishedAt = fmt.Sprintf("%v", row[9])
} }
newProducts = append(newProducts, structs.NewProduct{ newProducts = append(newProducts, structs.NewProduct{
@ -182,6 +197,7 @@ func fetchProducts(srv *sheets.Service) error {
Url: url, Url: url,
Variant: productVariant, Variant: productVariant,
Characteristics: productCharacteristics, Characteristics: productCharacteristics,
PublishedAt: publishedAt,
}) })
} }
} }