-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MINOR: add inserted_at column to trades #1646
Conversation
|
@@ -0,0 +1,11 @@ | |||
-- +up | |||
-- +begin | |||
ALTER TABLE `trades` ADD COLUMN `inserted_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use DATETIME(3) ?
pkg/types/trade.go
Outdated
@@ -95,6 +95,8 @@ type Trade struct { | |||
|
|||
// PnL is the profit and loss value of the executed trade | |||
PnL sql.NullFloat64 `json:"pnl" db:"pnl"` | |||
|
|||
InsertedAt time.Time `db:"inserted_at"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use types.Time here, it handles the datetime scan from db
7cbfe7c
to
8b1a0b5
Compare
e7b4abe
to
bd5e156
Compare
bd5e156
to
9ca225d
Compare
pkg/types/trade.go
Outdated
@@ -95,6 +95,8 @@ type Trade struct { | |||
|
|||
// PnL is the profit and loss value of the executed trade | |||
PnL sql.NullFloat64 `json:"pnl" db:"pnl"` | |||
|
|||
InsertedAt Time `db:"inserted_at"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add a json tag here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@c9s It's not returned by the server. The value is generated by mysql. Do we still have to add json tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we have some api renders the trade object in JSON format, but it's optional, not a problem
好像還是 test fail 可能要 rebase 一下 我猜可能是 bitget test failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
應該要rebase main
A trade may be missed initially and fetched after it has occurred.
9ca225d
to
49d567c
Compare
@ycdesu you need to sign CLA~ thanks |
A trade may be missed initially and fetched after it has occurred, so we add inserted_at column.