-
Notifications
You must be signed in to change notification settings - Fork 624
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
Add deposits and withdraws history to one API endpoint #2207
Conversation
app/api/v2/account/history.rb
Outdated
desc: 'Sorting order' | ||
|
||
optional :time_from, | ||
type: { value: Integer, message: 'account.history.non_integer_time_from' }, |
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.
add
allow_blank: { value: false, message: 'account.history.empty_time_from' },
app/api/v2/account/history.rb
Outdated
desc: 'An integer represents the seconds elapsed since Unix epoch.' | ||
|
||
optional :time_to, | ||
type: { value: Integer, message: 'account.history.non_integer_time_to' }, |
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.
allow_blank: { value: false, message: 'market.trade.empty_time_to' },
app/api/v2/account/history.rb
Outdated
type: { value: Integer, message: 'account.history.non_integer_time_to' }, | ||
desc: 'An integer represents the seconds elapsed since Unix epoch.' | ||
|
||
optional :page, |
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.
rewrite :page and :limit like in https://github.com/rubykube/peatio/blob/e9ccb2abedd1a018cd2aae02bf601531fe4b0b2d/app/api/v2/market/named_params.rb#L47
app/api/v2/account/history.rb
Outdated
ORDER BY updated_at #{params[:order_by].upcase}" | ||
|
||
result = ActiveRecord::Base.connection.exec_query(sql).to_hash | ||
.tap { |q| q.delete_if { |t| t['currency_id'] != params[:currency] } if params[:currency] } |
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.
please use 'select' or 'reject', cause delete_if change collection.
and you can avoid using tap
.select { ... }
.select { ... }
.tap { |q| present paginate(q) }
30c2f0f
to
e746305
Compare
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.
The main idea is described here
https://gist.github.com/ysv/6c4444c4a76db1a8068be8bae4e459da
e746305
to
a990750
Compare
config/database.yml
Outdated
@@ -10,7 +10,7 @@ default: &default | |||
|
|||
development: | |||
<<: *default | |||
database: peatio_development | |||
database: peatio_production |
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.
I don't think you want to commit that 😅
app/api/v2/account/history.rb
Outdated
|
||
end | ||
get "/history" do | ||
sql = "SELECT currency_id, amount, fee, address, aasm_state, NULL AS note, txid, updated_at, type FROM deposits WHERE member_id=#{current_user.id} \ |
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.
Looks like ORDER BY is applied only to second SELECT
Could you prepare spec for this scenario
SELECT FROM (SELECT UNION SELECT) order by q1.updated_at DESC |
a8d0c27
to
1b3151f
Compare
1b3151f
to
88fe709
Compare
@ymasiuk we need the same for master once QA approves this one |
This pr is working, but I would add filter: by type: Deposit/Withdraw Have similar feature/bug to mentioned above api endpoints. |
No description provided.