Class: AuctionFunCore::Relations::Bids
- Inherits:
-
Object
- Object
- AuctionFunCore::Relations::Bids
- Defined in:
- lib/auction_fun_core/relations/bids.rb
Overview
SQL relation for bids
Instance Method Summary collapse
-
#participants(auction_id) ⇒ Array<Integer>
Retrieves a list of unique user IDs who have placed bids in a specified auction.
Instance Method Details
#participants(auction_id) ⇒ Array<Integer>
Retrieves a list of unique user IDs who have placed bids in a specified auction. A participant in an auction is defined as a user who has placed one or more bids.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/auction_fun_core/relations/bids.rb', line 33 def participants(auction_id) raise "Invalid argument" unless auction_id.is_a?(Integer) sql = <<-SQL SELECT COALESCE(ARRAY_AGG(DISTINCT user_id), ARRAY[]::INT[]) AS participant_ids FROM bids WHERE auction_id = #{auction_id} SQL read(sql) end |