Skip to content

Commit

Permalink
aponta para novas tabelas da b3 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisanches authored Jun 28, 2022
1 parent 63e00f9 commit 514fc50
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 10 additions & 16 deletions cmd/guru.feeder.investor.corporate.actions.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
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() {
options.OPTIONS.Load()
}

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
}
4 changes: 2 additions & 2 deletions src/constants/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const (
)

const (
ManualSourceType = "REGULAR"
BonusOMSSourceType = "OMS"
ManualSourceType = "REGULAR"
BonusOMSSourceType = "OMS"
BonusInvestorSourceType = "InvestorB3"
)

Expand Down
1 change: 1 addition & 0 deletions src/repository/CEITransactionRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/repository/ConnectionRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/repository/CustomerRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/repository/SymbolRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/repository/mapper/cei_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mapper
import "time"

func (CEITransaction) TableName() string {
return "wallet.cei_transactions"
return "wallet.investor_transactions"
}

type CEITransaction struct {
Expand Down

0 comments on commit 514fc50

Please sign in to comment.