Skip to content

Commit

Permalink
refactor: Remove unnecessary whitespace and add TruncateClosedPnL fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
rluisr committed Feb 17, 2024
1 parent 46a9181 commit 6701ebe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/adapter/gateway/tv_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ func (r *TVRepository) GetUniqueSymbol() ([]string, error) {
err := r.RODB.Model(&domain.Order{}).Distinct("symbol").Find(&symbols).Error
return symbols, err
}

func (r *TVRepository) TruncateClosedPnL() error {
return r.RWDB.Exec("TRUNCATE closed_pnl;").Error
}
1 change: 1 addition & 0 deletions pkg/usecase/interfaces/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type TVRepository interface {
SaveClosedPnL(closedPnL []*domain.ClosedPnL) error
UpdateOrder(*domain.Order) error
GetUniqueSymbol() ([]string, error)
TruncateClosedPnL() error
}

type BybitRepository interface {
Expand Down
6 changes: 6 additions & 0 deletions pkg/usecase/tv_interactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func (i *TVInteractor) CreateOrder(c *gin.Context) (domain.TVOrderResponse, erro
}

func (i *TVInteractor) FetchPL() error {
// TODO TRUNCATE せずに増分更新する
err := i.TVRepository.TruncateClosedPnL()
if err != nil {
return err
}

symbols, err := i.TVRepository.GetUniqueSymbol()
if err != nil {
return err
Expand Down

0 comments on commit 6701ebe

Please sign in to comment.