Skip to content
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

Merged
merged 2 commits into from
Jun 18, 2024
Merged

Conversation

ycdesu
Copy link
Collaborator

@ycdesu ycdesu commented May 31, 2024

A trade may be missed initially and fetched after it has occurred, so we add inserted_at column.

@ycdesu ycdesu requested a review from c9s May 31, 2024 09:00
@CLAassistant
Copy link

CLAassistant commented May 31, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@c9s c9s changed the title minor: add inserted_at column minor: add inserted_at column to trades May 31, 2024
@@ -0,0 +1,11 @@
-- +up
-- +begin
ALTER TABLE `trades` ADD COLUMN `inserted_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL;
Copy link
Owner

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) ?

@@ -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"`
Copy link
Owner

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

@ycdesu ycdesu force-pushed the minor/add-inserted-at-to-trade branch 2 times, most recently from 7cbfe7c to 8b1a0b5 Compare May 31, 2024 09:38
@c9s c9s changed the title minor: add inserted_at column to trades MINOR: add inserted_at column to trades Jun 3, 2024
@ycdesu ycdesu force-pushed the minor/add-inserted-at-to-trade branch from e7b4abe to bd5e156 Compare June 4, 2024 07:11
@ycdesu ycdesu requested a review from c9s June 4, 2024 07:11
@ycdesu ycdesu force-pushed the minor/add-inserted-at-to-trade branch from bd5e156 to 9ca225d Compare June 4, 2024 07:19
@@ -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"`
Copy link
Owner

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?

Copy link
Collaborator Author

@ycdesu ycdesu Jun 4, 2024

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?

Copy link
Owner

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

@ycdesu ycdesu requested a review from c9s June 4, 2024 10:18
@c9s
Copy link
Owner

c9s commented Jun 13, 2024

好像還是 test fail 可能要 rebase 一下 我猜可能是 bitget test failed

Copy link
Collaborator

@bailantaotao bailantaotao left a 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.
@ycdesu ycdesu force-pushed the minor/add-inserted-at-to-trade branch from 9ca225d to 49d567c Compare June 17, 2024 09:42
@ycdesu ycdesu requested review from c9s and bailantaotao June 17, 2024 11:24
@c9s
Copy link
Owner

c9s commented Jun 17, 2024

@ycdesu you need to sign CLA~ thanks

@ycdesu ycdesu merged commit c83524a into main Jun 18, 2024
2 of 3 checks passed
@ycdesu ycdesu deleted the minor/add-inserted-at-to-trade branch June 18, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants