Skip to content

Commit

Permalink
add requests test for favorite merchant and date merchant by items sold
Browse files Browse the repository at this point in the history
  • Loading branch information
vidoseaver committed Dec 2, 2016
1 parent 8a547cf commit c80693c
Show file tree
Hide file tree
Showing 8 changed files with 547 additions and 244 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Api::V1::Merchants::CustomersWithPendingInvoicesController < ApplicationController

def index
render json: Merchant.customers_with_pending_invoices(params[:merchant_id])
end

end
1 change: 1 addition & 0 deletions app/models/merchant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def self.top_merchants_by_items_sold(number)

def customers_with_pending_invoices
customers.where(id: invoices.pending.pluck('DISTINCT customer_id')).uniq
# ActiveRecord::Base.connection.execute("SELECT * FROM customers WHERE customers.id IN (SELECT customer_id FROM invoices WHERE invoices.merchant_id = #{merchant_id.to_i} AND NOT EXISTS (SELECT * FROM transactions WHERE transactions.invoice_id = invoices.id AND transactions.result = 'success'))")
end

end
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"covered_percent": 95.38
"covered_percent": 96.25
}
}
Loading

0 comments on commit c80693c

Please sign in to comment.