71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
|
|
"t0xa/pdf_to_txt/internal/migrator"
|
|
)
|
|
|
|
type CheckEntry struct {
|
|
Product string
|
|
Price string
|
|
}
|
|
|
|
func main() {
|
|
// TODO: Redo format of file passing to function
|
|
// text := parser.ParseX5Check("./internal/parser/testfiles/test3.pdf")
|
|
//
|
|
// split := strings.Split(text, "\n") stringsToFilter := "https://mail|Gmail - Электронный чек|Сумма|НДС"
|
|
// re := regexp.MustCompile(stringsToFilter)
|
|
// filtered := []string{}
|
|
// for _, element := range split {
|
|
// if re.MatchString(element) {
|
|
// continue
|
|
// }
|
|
// if len(element) < 1 {
|
|
// continue
|
|
// }
|
|
// filtered = append(filtered, element)
|
|
//
|
|
// }
|
|
// for index, element := range filtered {
|
|
// if element == "Цена*Кол" {
|
|
// fmt.Println("Товар: ", filtered[index-1])
|
|
// fmt.Println("Цена: ", filtered[index+1])
|
|
// fmt.Println("------")
|
|
// }
|
|
// }
|
|
|
|
// ctx := context.Background()
|
|
//
|
|
// conn, err := pgx.Connect(ctx, "postgres://ruprod_user:ruprod_password@localhost:5433/ruprod")
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// defer conn.Close(ctx)
|
|
//
|
|
// queries := ruprod.New(conn)
|
|
// insertedProduct, err := queries.CreateProduct(ctx, ruprod.CreateProductParams{
|
|
// Name: "Сырок",
|
|
// Price: pgtype.Float8{Float64: 12.9, Valid: true},
|
|
// PurchaseDate: pgtype.Timestamp{Time: time.Now()},
|
|
// })
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// fmt.Println(insertedProduct)
|
|
|
|
ctx := context.Background()
|
|
conn, err := pgx.Connect(ctx, "postgres://ruprod_user:ruprod_password@localhost:5433/ruprod")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer conn.Close(ctx)
|
|
|
|
if err := migrator.Migrate(ctx, conn); err != nil {
|
|
log.Fatalf("Migration failed: %s", err)
|
|
}
|
|
}
|