Skip to content

Commit

Permalink
updated logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov authored and Oleg Hasjanov committed Jan 25, 2024
1 parent 51c619d commit dfa2281
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/auctions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AuctionsController < ApplicationController
skip_before_action :verify_authenticity_token

def show
@auction = Auction.english.find_by!(uuid: params[:auction_id])
@auction = Auction.find_by!(uuid: params[:auction_id])
offer = @auction.offer_from_user(current_user.id)
autobider = current_user.autobiders.find_or_initialize_by(domain_name: @auction.domain_name)
billing_profiles = BillingProfile.accessible_by(current_ability).where(user_id: current_user.id)
Expand Down
37 changes: 27 additions & 10 deletions app/controllers/api/v1/offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,53 @@ class OffersController < ApplicationController

skip_before_action :verify_authenticity_token

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def create
Rails.logger.info('----')
Rails.logger.info(params)
Rails.logger.info('----')

auction = Auction.find_by(uuid: params[:bid][:auction_id])
return if auction.nil?

offer = auction.offer_from_user(current_user.uuid)

billing_profile = current_user.billing_profiles.find_by(uuid: params[:bid][:billing_profile_id])

billing_profile = current_user.billing_profiles.find_by(id: params[:bid][:billing_profile_id])

Rails.logger.info('----')
Rails.logger.info(billing_profile.inspect)
Rails.logger.info('----')

if offer.nil?
offer = Offer.new(
auction: auction,
auction:,
user: current_user,
cents: Money.from_amount(params[:bid][:price]).cents,
billing_profile: billing_profile,
username: Username::GenerateUsernameService.new.call
billing_profile:,
username: auction.english? ? Username::GenerateUsernameService.new.call : nil
)
else
offer.cents = Money.from_amount(params[:bid][:price]).cents
end

if offer.save
Auctions::UpdateListBroadcastService.call({ auction: auction })
if auction.english?
Auctions::UpdateListBroadcastService.call({ auction: })

auction.update_minimum_bid_step(params[:bid][:price].to_f)
auction.update_minimum_bid_step(params[:bid][:price].to_f)

AutobiderService.autobid(auction)
auction.update_ends_at(offer)
AutobiderService.autobid(auction)
auction.update_ends_at(offer)
end

render json: { status: 'ok' }, status: :ok
else

Rails.logger.info('----')
Rails.logger.info(offer.errors.inspect)
Rails.logger.info('----')

render json: { status: 'error' }, status: :unprocessable_entity
end
end
Expand Down

0 comments on commit dfa2281

Please sign in to comment.