Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. @conversation = Conversation.includes(:messages)
  2. .get_coach_conversations(@seller)
  3.  
  4. def self.get_seller_conversations(seller)
  5. @conversations = seller.conversations
  6. .includes(buyer: [:purchases, :user])
  7. .joins(:messages)
  8. .where(messages: {only_for_buyer: false})
  9. .distinct
  10. new.sorted_conversations(@conversations)
  11. end
  12.  
  13. def sorted_conversations(conversations)
  14. conversations.sort_by { |c| c.messages.last.created_at }
  15. .reverse
  16. end
  17.  
  18. json.array!(@conversations.map do |c|
  19. ...
  20. ...
  21. already_client: c.buyer.purchases
  22. .where(seller: @seller)
  23. .where('subscription = ? OR product_price > ?',
  24. true, 0)
  25. .exists?
  26. end)
Add Comment
Please, Sign In to add comment