auctify 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -9
- data/app/controllers/auctify/api/v1/auctions_controller.rb +15 -8
- data/app/models/auctify/bid.rb +1 -0
- data/app/models/auctify/bidder_registration.rb +12 -9
- data/app/models/auctify/sale/auction.rb +2 -10
- data/db/migrate/20230905114142_add_confirmed_sales_pack_terms_to_bidder_registrations.rb +9 -0
- data/lib/auctify/railtie.rb +7 -4
- data/lib/auctify/version.rb +1 -1
- data/lib/auctify.rb +1 -4
- data/lib/tasks/test_tasks.rake +8 -0
- data/lib/yabeda_config.rb +26 -7
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e40c33ab5508a5874d200e861cebe30e1c7b9b99dd0d6a24376998f7eca011c
|
4
|
+
data.tar.gz: 026de4ef6565e73d83e0e9e433cca5872a6be4a4a92aa1e5b85b2ec64a44ad99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f1c2cce869ea2fd00ca4a8a078d4f5febb15b0ce328682847a47cbdc5b2410fd120e55c5d54ee79ea5f38388ef87157232d2b0fc133f81931f1b4f4dc77246f
|
7
|
+
data.tar.gz: c07420c8fa9d289d99f947e4debcb653cc0a34c2c24500878d8317482fd39201054aec71d36b83d7b80994ad77b9b53d85b5648fe44fae3e5f777202aa4e11cb
|
data/Rakefile
CHANGED
@@ -23,12 +23,11 @@ load "rails/tasks/statistics.rake"
|
|
23
23
|
|
24
24
|
require "bundler/gem_tasks"
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
Rake::TestTask.new(:test) do |t|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
task default: :test
|
26
|
+
## use `rails test` instead
|
27
|
+
# require "rake/testtask"
|
28
|
+
# Rake::TestTask.new(:test) do |t|
|
29
|
+
# t.libs << "test"
|
30
|
+
# t.pattern = "test/**/*_test.rb"
|
31
|
+
# t.verbose = false
|
32
|
+
# end
|
33
|
+
# task default: :test
|
@@ -15,15 +15,15 @@ module Auctify
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def bids
|
18
|
-
if params[:
|
18
|
+
if params[:terms_confirmation] == "1"
|
19
19
|
if @auction.bid!(new_bid)
|
20
20
|
@auction.reload
|
21
21
|
|
22
|
-
|
22
|
+
store_confirmations_checkboxes
|
23
23
|
|
24
24
|
render_record @auction, success: true, overbid_by_limit: overbid_by_limit?(new_bid)
|
25
25
|
else
|
26
|
-
|
26
|
+
store_confirmations_checkboxes
|
27
27
|
|
28
28
|
render_record @auction, bid: new_bid, status: 400
|
29
29
|
end
|
@@ -63,11 +63,18 @@ module Auctify
|
|
63
63
|
}, status: status
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
def store_confirmations_checkboxes
|
67
|
+
bidder_regs = current_user.bidder_registrations.where(auction: @auction)
|
68
|
+
if bidder_regs.present?
|
69
|
+
atts = { dont_confirm_bids: params[:dont_confirm_bids] == "1",
|
70
|
+
confirmed_sales_pack_terms: params[:terms_confirmation] == "1" }
|
71
|
+
bidder_regs.update_all(atts)
|
72
|
+
|
73
|
+
if atts[:confirmed_sales_pack_terms]
|
74
|
+
current_user.bidder_registrations.for_pack(bidder_regs.last.auction.pack)
|
75
|
+
.where(confirmed_sales_pack_terms: false)
|
76
|
+
.update_all(confirmed_sales_pack_terms: true)
|
77
|
+
end
|
71
78
|
end
|
72
79
|
end
|
73
80
|
|
data/app/models/auctify/bid.rb
CHANGED
@@ -8,6 +8,7 @@ module Auctify
|
|
8
8
|
scope :applied, -> { where(cancelled: false) }
|
9
9
|
scope :canceled, -> { where(cancelled: true) }
|
10
10
|
scope :with_limit, -> { where.not(max_price: nil) }
|
11
|
+
scope :manual, -> { where(autobid: false) }
|
11
12
|
|
12
13
|
validate :price_is_not_bigger_then_max_price
|
13
14
|
validate :price_is_rounded
|
@@ -17,6 +17,8 @@ module Auctify
|
|
17
17
|
inverse_of: :registration,
|
18
18
|
dependent: :restrict_with_error # destroy them manually first
|
19
19
|
|
20
|
+
scope :for_pack, ->(pack) { where(auction: pack.sales) }
|
21
|
+
|
20
22
|
aasm do
|
21
23
|
state :pending, initial: true, color: "gray"
|
22
24
|
state :approved, color: "green"
|
@@ -81,15 +83,16 @@ end
|
|
81
83
|
#
|
82
84
|
# Table name: auctify_bidder_registrations
|
83
85
|
#
|
84
|
-
# id
|
85
|
-
# bidder_type
|
86
|
-
# bidder_id
|
87
|
-
# auction_id
|
88
|
-
# aasm_state
|
89
|
-
# handled_at
|
90
|
-
# created_at
|
91
|
-
# updated_at
|
92
|
-
# dont_confirm_bids
|
86
|
+
# id :bigint(8) not null, primary key
|
87
|
+
# bidder_type :string not null
|
88
|
+
# bidder_id :bigint(8) not null
|
89
|
+
# auction_id :bigint(8) not null
|
90
|
+
# aasm_state :string default("pending"), not null
|
91
|
+
# handled_at :datetime
|
92
|
+
# created_at :datetime not null
|
93
|
+
# updated_at :datetime not null
|
94
|
+
# dont_confirm_bids :boolean default(FALSE)
|
95
|
+
# confirmed_sales_pack_terms :boolean default(FALSE)
|
93
96
|
#
|
94
97
|
# Indexes
|
95
98
|
#
|
@@ -71,7 +71,7 @@ module Auctify
|
|
71
71
|
self.winner = current_winner
|
72
72
|
|
73
73
|
now = Time.current
|
74
|
-
Yabeda.auctify.diff_in_closing_time_seconds.set({}, (now - self.currently_ends_at))
|
74
|
+
Yabeda.auctify.diff_in_closing_time_seconds.set({}, (now - self.currently_ends_at).round)
|
75
75
|
self.currently_ends_at = now if now < currently_ends_at
|
76
76
|
|
77
77
|
after_close_bidding
|
@@ -163,15 +163,7 @@ module Auctify
|
|
163
163
|
|
164
164
|
bap = Auctify::BidsAppender.call(auction: self, bid: bid)
|
165
165
|
|
166
|
-
|
167
|
-
after_bid_appended(bap)
|
168
|
-
|
169
|
-
Yabeda.auctify.bids_count.increment({}, by: 1)
|
170
|
-
times = ordered_applied_bids.limit(2).pluck(:created_at)
|
171
|
-
Yabeda.auctify.time_between_bids.set({ auction_slug: slug }, (times.size == 1 ? 0 : times.first - times.second))
|
172
|
-
else
|
173
|
-
after_bid_not_appended(bap)
|
174
|
-
end
|
166
|
+
bap.success? ? after_bid_appended(bap) : after_bid_not_appended(bap)
|
175
167
|
|
176
168
|
bap.success?
|
177
169
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddConfirmedSalesPackTermsToBidderRegistrations < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
add_column :auctify_bidder_registrations, :confirmed_sales_pack_terms, :boolean, default: false
|
6
|
+
|
7
|
+
execute "UPDATE auctify_bidder_registrations SET confirmed_sales_pack_terms = true WHERE dont_confirm_bids = true;"
|
8
|
+
end
|
9
|
+
end
|
data/lib/auctify/railtie.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "yabeda/prometheus"
|
4
|
-
|
5
3
|
module Auctify
|
6
4
|
class Railtie < Rails::Railtie
|
7
|
-
|
8
|
-
|
5
|
+
# I did not found way, how to chec for presence of Yabeda::Prometheus::Exporter in middleware
|
6
|
+
if require "yabeda/prometheus"
|
7
|
+
initializer "auctify.railtie_initialization" do |main_app|
|
8
|
+
main_app.middleware.use ::Yabeda::Prometheus::Exporter
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
13
|
+
|
14
|
+
require "yabeda_config.rb"
|
data/lib/auctify/version.rb
CHANGED
data/lib/auctify.rb
CHANGED
data/lib/yabeda_config.rb
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "yabeda/prometheus"
|
4
|
-
|
5
3
|
Yabeda.configure do
|
6
4
|
group :auctify do
|
7
|
-
|
8
|
-
|
5
|
+
gauge :bids_count,
|
6
|
+
comment: "A count of all applied bids"
|
7
|
+
# counter :bids_count, comment: "A count of all applied bids"
|
8
|
+
gauge :time_between_last_bids_seconds,
|
9
|
+
comment: "Time period between last two manual bids"
|
10
|
+
gauge :current_max_delay_in_closing_auction_seconds,
|
11
|
+
comment: "Delay from oldest `currently_ends_at` of auction in sale (that should be already closed)."
|
12
|
+
|
13
|
+
|
14
|
+
# this is done when auction.close_bidding! is run
|
15
|
+
gauge :diff_in_closing_time_seconds,
|
9
16
|
comment: "Difference between auction.currently_ends_at and actual sale end time by job"
|
10
|
-
|
11
|
-
end
|
17
|
+
end
|
12
18
|
|
19
|
+
# to fetch correct data independently on process/container
|
20
|
+
# we collect them at request for /metrics, not at "trigger" time
|
13
21
|
collect do # when /metrics is displayed
|
14
|
-
|
22
|
+
auctify.bids_count.set({}, Auctify::Bid.count)
|
23
|
+
|
24
|
+
last_bid_times = Auctify::Bid.applied.manual.order(created_at: :desc).limit(2).pluck(:created_at)
|
25
|
+
auctify.time_between_last_bids_seconds.set({}, last_bid_times.size == 2 ? (last_bid_times.first - last_bid_times.last).round : 0)
|
26
|
+
|
27
|
+
auction = Auctify::Sale::Auction.in_sale.order(currently_ends_at: :asc).first
|
28
|
+
if auction.blank?
|
29
|
+
auctify.current_max_delay_in_closing_auction_seconds.set({}, -1)
|
30
|
+
else
|
31
|
+
delay = [0, (Time.current - auction.currently_ends_at)].max # only positive number
|
32
|
+
auctify.current_max_delay_in_closing_auction_seconds.set({}, delay.round)
|
33
|
+
end
|
15
34
|
end
|
16
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auctify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- foton
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -439,18 +439,20 @@ files:
|
|
439
439
|
- db/migrate/20210917082313_add_auction_prolonging_limit_to_sales_packs.rb
|
440
440
|
- db/migrate/20211022133253_add_autobid_to_auctify_bids.rb
|
441
441
|
- db/migrate/20211203064934_update_sales_featurable.rb
|
442
|
+
- db/migrate/20230905114142_add_confirmed_sales_pack_terms_to_bidder_registrations.rb
|
442
443
|
- lib/auctify.rb
|
443
444
|
- lib/auctify/configuration.rb
|
444
445
|
- lib/auctify/engine.rb
|
445
446
|
- lib/auctify/railtie.rb
|
446
447
|
- lib/auctify/version.rb
|
447
448
|
- lib/tasks/auctify_tasks.rake
|
449
|
+
- lib/tasks/test_tasks.rake
|
448
450
|
- lib/yabeda_config.rb
|
449
451
|
homepage: https://github.com/sinfin/auctify
|
450
452
|
licenses:
|
451
453
|
- MIT
|
452
454
|
metadata: {}
|
453
|
-
post_install_message:
|
455
|
+
post_install_message:
|
454
456
|
rdoc_options: []
|
455
457
|
require_paths:
|
456
458
|
- lib
|
@@ -465,8 +467,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
465
467
|
- !ruby/object:Gem::Version
|
466
468
|
version: '0'
|
467
469
|
requirements: []
|
468
|
-
rubygems_version: 3.
|
469
|
-
signing_key:
|
470
|
+
rubygems_version: 3.0.3
|
471
|
+
signing_key:
|
470
472
|
specification_version: 4
|
471
473
|
summary: Gem for adding auction behavior to models.
|
472
474
|
test_files: []
|