add parsing sumpays
All checks were successful
Build and push image / deploy (push) Successful in 1m44s
All checks were successful
Build and push image / deploy (push) Successful in 1m44s
This commit is contained in:
@ -6,11 +6,11 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.home.4it.me/dilap54/platiparser/gorm"
|
||||
"gitea.home.4it.me/dilap54/platiparser/healthbeat"
|
||||
"gitea.home.4it.me/dilap54/platiparser/internal/category"
|
||||
"gitea.home.4it.me/dilap54/platiparser/plati"
|
||||
"gitea.home.4it.me/dilap54/platiparser/proxies"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
@ -27,8 +27,8 @@ var platiCommand = &cli.Command{
|
||||
Action: func(c *cli.Context) error {
|
||||
timeStart := time.Now()
|
||||
|
||||
categories := openCategories("./categories.json").Content
|
||||
categories = filterBySubstring("Gift", categories)
|
||||
categories := category.OpenCategories("./categories.json").Content
|
||||
categories = category.FilterBySubstring("Gift", categories)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@ -101,22 +101,6 @@ func convertGoodsToGorm(cat *plati.Category, goods []*plati.Good) []*gorm.Good {
|
||||
return out
|
||||
}
|
||||
|
||||
func filterBySubstring(substring string, categories plati.Categories) plati.Categories {
|
||||
out := make(plati.Categories, 0)
|
||||
for _, c := range categories {
|
||||
if len(c.Children) > 0 {
|
||||
out = append(out, filterBySubstring(substring, c.Children)...)
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(c.FlatName, substring) {
|
||||
out = append(out, c)
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func printNames(categories plati.Categories) {
|
||||
for _, c := range categories {
|
||||
if len(c.Children) > 0 {
|
||||
@ -126,19 +110,3 @@ func printNames(categories plati.Categories) {
|
||||
fmt.Printf("%s\n", c.FlatName)
|
||||
}
|
||||
}
|
||||
|
||||
func openCategories(fileName string) plati.CategoriesResponse {
|
||||
f, err := os.OpenFile(fileName, os.O_RDONLY, 0400)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
out := plati.CategoriesResponse{}
|
||||
if err := json.NewDecoder(f).Decode(&out); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
out.Content.FlatNames("")
|
||||
out.Content.FixParentID(0)
|
||||
return out
|
||||
}
|
||||
|
Reference in New Issue
Block a user