allow to skip item by created

This commit is contained in:
Aleksandr Trushkin
2024-02-04 22:13:39 +03:00
parent a224f249d5
commit e91eec7aeb
7 changed files with 51 additions and 3 deletions

View File

@ -899,6 +899,7 @@ func parseEwayDumpAction(ctx context.Context, cmd *cli.Command) error {
fetchedInfo int
handledAll int
cachedInfo int
skippedItem int
}{}
startFrom := time.Now()
@ -934,6 +935,14 @@ func parseEwayDumpAction(ctx context.Context, cmd *cli.Command) error {
for _, item := range items {
var pi entity.GoodsItemInfo
seenItem := seenItems[item.SKU]
if time.Since(seenItem.CreatedAt) < time.Hour*24 {
logger.Debug().Str("sku", item.SKU).Msg("skipping item because it's too fresh")
stats.skippedItem++
itemsUpdated[item.SKU] = struct{}{}
continue
}
if len(seenItem.Parameters) != 0 && len(seenItem.PhotoURLs) != 0 {
pi.Parameters = seenItem.Parameters
pi.PhotoURLs = seenItem.PhotoURLs
@ -1015,6 +1024,7 @@ func parseEwayDumpAction(ctx context.Context, cmd *cli.Command) error {
Int("handled", stats.handledAll).
Int("cached", stats.cachedInfo).
Int("fetched", stats.fetchedInfo).
Int("skipped", stats.skippedItem).
Int("to_delete", len(seenItems)).
Msg("processed items")