diff --git a/Dockerfile b/Dockerfile index ed5fe8a..0ebabbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,11 @@ WORKDIR $GOPATH/src/github.com/guru-invest/guru.feeder.investor.corporate.action COPY . . -RUN apk add tzdata && \ - cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && \ - echo "America/Sao_Paulo" > /etc/timezone && \ - date && \ - apk del tzdata +# RUN apk add tzdata && \ +# cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && \ +# echo "America/Sao_Paulo" > /etc/timezone && \ +# date && \ +# apk del tzdata RUN go build -ldflags '-linkmode=external' -mod vendor -o guru.feeder.investor.corporate.actions ./cmd/guru.feeder.investor.corporate.actions.go diff --git a/cmd/guru.feeder.investor.corporate.actions.go b/cmd/guru.feeder.investor.corporate.actions.go index 95fa527..4a9474d 100644 --- a/cmd/guru.feeder.investor.corporate.actions.go +++ b/cmd/guru.feeder.investor.corporate.actions.go @@ -1,14 +1,8 @@ package main import ( - "os" - "os/signal" - "syscall" - "time" - "github.com/guru-invest/guru.feeder.investor.corporate.actions/src/core" "github.com/guru-invest/guru.feeder.investor.corporate.actions/src/crossCutting/options" - "github.com/robfig/cron/v3" ) func init() { @@ -16,17 +10,17 @@ func init() { } func main() { - time_zone, _ := time.LoadLocation("America/Sao_Paulo") + //time_zone, _ := time.LoadLocation("America/Sao_Paulo") - //core.ApplyEvents("fzVzgo8b") - //core.ApplyEventsAfterInvestorSync("fzVzgo8b") - //core.Run() + //core.ApplyEvents("adR2JN3b") + //core.ApplyEventsAfterInvestorSync("Ayqi8gfb") + core.Run() - c := cron.New(cron.WithLocation(time_zone)) - c.AddFunc("30 2 * * *", func() { core.Run() }) - go c.Start() - sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt, syscall.SIGTERM) + // c := cron.New(cron.WithLocation(time_zone)) + // c.AddFunc("30 2 * * *", func() { core.Run() }) + // go c.Start() + // sig := make(chan os.Signal, 1) + // signal.Notify(sig, os.Interrupt, syscall.SIGTERM) - <-sig + // <-sig } diff --git a/src/constants/events.go b/src/constants/events.go index 9fa0e0c..e5980a9 100644 --- a/src/constants/events.go +++ b/src/constants/events.go @@ -21,8 +21,8 @@ const ( ) const ( - ManualSourceType = "REGULAR" - BonusOMSSourceType = "OMS" + ManualSourceType = "REGULAR" + BonusOMSSourceType = "OMS" BonusInvestorSourceType = "InvestorB3" ) diff --git a/src/repository/CEITransactionRepository.go b/src/repository/CEITransactionRepository.go index 69b4cee..4210ed2 100644 --- a/src/repository/CEITransactionRepository.go +++ b/src/repository/CEITransactionRepository.go @@ -23,6 +23,7 @@ func (h CEITransactionRepository) getCEITransactions(customers []mapper.Customer err := h._connection._databaseConnection. Select("id, customer_code, symbol, broker_id, quantity, price, amount, side, trade_date, post_event_quantity, post_event_price, post_event_symbol, event_factor, event_date, event_name"). Where("customer_code in ?", in_customers). + Where("movement_type = ?", "Assets-Trading"). Order("trade_date asc"). Find(&cei_transaction). Error diff --git a/src/repository/ConnectionRepository.go b/src/repository/ConnectionRepository.go index 4f88089..52ee219 100644 --- a/src/repository/ConnectionRepository.go +++ b/src/repository/ConnectionRepository.go @@ -20,13 +20,12 @@ func (db *DatabaseConnection) connect() { DATABASE := options.OPTIONS.DATABASE dsn := fmt.Sprintf( - "user=%s password=%s dbname=%s host=%s port=%s timezone=%s", + "user=%s password=%s dbname=%s host=%s port=%s", DATABASE.Username, DATABASE.Password, DATABASE.Database, DATABASE.Url, - DATABASE.Port, - "America/Sao_Paulo") + DATABASE.Port) newLogger := logger.New( log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer diff --git a/src/repository/CustomerRepository.go b/src/repository/CustomerRepository.go index b6d8693..54f21b8 100644 --- a/src/repository/CustomerRepository.go +++ b/src/repository/CustomerRepository.go @@ -63,7 +63,12 @@ func (h CustomerRepository) getCEICustomers() ([]mapper.Customer, error) { defer h._connection.disconnect() var customer []mapper.Customer - err := h._connection._databaseConnection.Table("wallet.cei_items_status").Distinct("customer_code").Where("execution_status = ?", "SUCCESS").Find(&customer).Error + err := h._connection._databaseConnection. + Table("wallet.investor_sync_historical"). + Distinct("customer_code"). + Where("execution_status = ? AND event_type = ?", "SUCCESS", "movementEquities"). + Order("created_at DESC"). + Find(&customer).Error if err != nil { return []mapper.Customer{}, err } diff --git a/src/repository/SymbolRepository.go b/src/repository/SymbolRepository.go index 4749368..9d2e7c9 100644 --- a/src/repository/SymbolRepository.go +++ b/src/repository/SymbolRepository.go @@ -51,7 +51,7 @@ func (h SymbolRepository) getCEISymbols(customers []mapper.Customer) ([]mapper.S in_customers = append(in_customers, value.CustomerCode) } - err := h._connection._databaseConnection.Table("wallet.cei_transactions").Distinct("symbol").Where("customer_code in ?", in_customers).Find(&symbol).Error + err := h._connection._databaseConnection.Table("wallet.investor_transactions").Distinct("symbol").Where("customer_code in ?", in_customers).Find(&symbol).Error if err != nil { return []mapper.Symbol{}, err } diff --git a/src/repository/mapper/cei_transaction.go b/src/repository/mapper/cei_transaction.go index de58835..9c6e7b9 100644 --- a/src/repository/mapper/cei_transaction.go +++ b/src/repository/mapper/cei_transaction.go @@ -3,7 +3,7 @@ package mapper import "time" func (CEITransaction) TableName() string { - return "wallet.cei_transactions" + return "wallet.investor_transactions" } type CEITransaction struct {