auctify 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/Rakefile +8 -9
- data/app/controllers/auctify/api/v1/auctions_controller.rb +15 -8
- data/app/jobs/auctify/application_job.rb +4 -0
- data/app/jobs/auctify/bidding_closer_job.rb +8 -5
- data/app/jobs/auctify/ensure_auctions_closing_job.rb +3 -1
- data/app/models/auctify/bid.rb +1 -0
- data/app/models/auctify/bidder_registration.rb +12 -9
- data/app/models/auctify/sale/auction.rb +3 -0
- data/db/migrate/20230905114142_add_confirmed_sales_pack_terms_to_bidder_registrations.rb +9 -0
- data/lib/auctify/railtie.rb +14 -0
- data/lib/auctify/version.rb +1 -1
- data/lib/auctify.rb +2 -0
- data/lib/tasks/test_tasks.rake +8 -0
- data/lib/yabeda_config.rb +35 -0
- metadata +24 -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/README.md
CHANGED
|
@@ -221,7 +221,19 @@ end
|
|
|
221
221
|
|
|
222
222
|
To protect accidential deletions, many associations are binded with `dependent: restrict_with_error`. Correct order ofdeletion is `bids` => `sales` => `sales_packs`.
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
## Monitor it
|
|
225
|
+
Auctify should add some metrics for Prometheus (using Yabeda gem). Exposing them on `/metrics` path.
|
|
226
|
+
```
|
|
227
|
+
group :auctify do
|
|
228
|
+
counter :bids_count, comment: "A counter of applied bids"
|
|
229
|
+
gauge :diff_in_closing_time_seconds,
|
|
230
|
+
comment: "Difference between auction.currently_ends_at and actual sale end time by job"
|
|
231
|
+
gauge :time_between_bids, comment: "Time period between last two bids", tags: [:auction_slug]
|
|
232
|
+
end
|
|
233
|
+
```
|
|
234
|
+
See `lib/yabeda_config.rb` for current setup.
|
|
235
|
+
Note: `diff_in_closing_time_seconds` is fill in `auction.close_bidding!`. At normal setup this is done in background job, so value is maintained in BJ process not rails app.
|
|
236
|
+
Eg. if You use sidekiq for backgoud jobs, You will need `yabeda-sidekiq` gem and then value vwill be displayed at port 9394 (`your.app:9394/metrics`).
|
|
225
237
|
|
|
226
238
|
## Contributing
|
|
227
239
|
Contribution directions go here.
|
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
|
|
|
@@ -12,11 +12,14 @@ module Auctify
|
|
|
12
12
|
return
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if Time.current < auction.currently_ends_at
|
|
16
|
+
Rails.logger.info("Too soon for closing of auction #{auction_label(auction)}.")
|
|
17
|
+
else
|
|
18
|
+
Rails.logger.info("Closing auction #{auction_label(auction)} NOW!")
|
|
19
|
+
Auctify::Sale::Auction.with_advisory_lock("closing_auction_#{auction_id}") do
|
|
20
|
+
# can wait unitl other BCJob release lock and than continue!
|
|
21
|
+
auction.close_bidding! if auction.reload.in_sale?
|
|
22
|
+
end
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Auctify
|
|
4
|
-
class EnsureAuctionsClosingJob < ApplicationJob
|
|
4
|
+
class EnsureAuctionsClosingJob < Auctify::ApplicationJob
|
|
5
5
|
queue_as :critical
|
|
6
6
|
|
|
7
7
|
def perform
|
|
@@ -9,8 +9,10 @@ module Auctify
|
|
|
9
9
|
.where("currently_ends_at <= ?", Time.current + checking_period_to_future)
|
|
10
10
|
auctions.each do |auction|
|
|
11
11
|
if auction.currently_ends_at <= Time.current
|
|
12
|
+
Rails.logger.info("Queueing auction #{auction_label(auction)} for immediate close.")
|
|
12
13
|
Auctify::BiddingCloserJob.perform_later(auction_id: auction.id)
|
|
13
14
|
else
|
|
15
|
+
Rails.logger.info("Delaying close of auction #{auction_label(auction)}.")
|
|
14
16
|
Auctify::BiddingCloserJob.set(wait_until: auction.currently_ends_at).perform_later(auction_id: auction.id)
|
|
15
17
|
end
|
|
16
18
|
end
|
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
|
#
|
|
@@ -69,7 +69,9 @@ module Auctify
|
|
|
69
69
|
|
|
70
70
|
after do
|
|
71
71
|
self.winner = current_winner
|
|
72
|
+
|
|
72
73
|
now = Time.current
|
|
74
|
+
Yabeda.auctify.diff_in_closing_time_seconds.set({}, (now - self.currently_ends_at).round)
|
|
73
75
|
self.currently_ends_at = now if now < currently_ends_at
|
|
74
76
|
|
|
75
77
|
after_close_bidding
|
|
@@ -162,6 +164,7 @@ module Auctify
|
|
|
162
164
|
bap = Auctify::BidsAppender.call(auction: self, bid: bid)
|
|
163
165
|
|
|
164
166
|
bap.success? ? after_bid_appended(bap) : after_bid_not_appended(bap)
|
|
167
|
+
|
|
165
168
|
bap.success?
|
|
166
169
|
end
|
|
167
170
|
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
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Auctify
|
|
4
|
+
class Railtie < Rails::Railtie
|
|
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
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require "yabeda_config.rb"
|
data/lib/auctify/version.rb
CHANGED
data/lib/auctify.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Yabeda.configure do
|
|
4
|
+
group :auctify do
|
|
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,
|
|
16
|
+
comment: "Difference between auction.currently_ends_at and actual sale end time by job"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# to fetch correct data independently on process/container
|
|
20
|
+
# we collect them at request for /metrics, not at "trigger" time
|
|
21
|
+
collect do # when /metrics is displayed
|
|
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
|
|
34
|
+
end
|
|
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
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: yabeda-prometheus
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: pg
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -425,16 +439,20 @@ files:
|
|
|
425
439
|
- db/migrate/20210917082313_add_auction_prolonging_limit_to_sales_packs.rb
|
|
426
440
|
- db/migrate/20211022133253_add_autobid_to_auctify_bids.rb
|
|
427
441
|
- db/migrate/20211203064934_update_sales_featurable.rb
|
|
442
|
+
- db/migrate/20230905114142_add_confirmed_sales_pack_terms_to_bidder_registrations.rb
|
|
428
443
|
- lib/auctify.rb
|
|
429
444
|
- lib/auctify/configuration.rb
|
|
430
445
|
- lib/auctify/engine.rb
|
|
446
|
+
- lib/auctify/railtie.rb
|
|
431
447
|
- lib/auctify/version.rb
|
|
432
448
|
- lib/tasks/auctify_tasks.rake
|
|
449
|
+
- lib/tasks/test_tasks.rake
|
|
450
|
+
- lib/yabeda_config.rb
|
|
433
451
|
homepage: https://github.com/sinfin/auctify
|
|
434
452
|
licenses:
|
|
435
453
|
- MIT
|
|
436
454
|
metadata: {}
|
|
437
|
-
post_install_message:
|
|
455
|
+
post_install_message:
|
|
438
456
|
rdoc_options: []
|
|
439
457
|
require_paths:
|
|
440
458
|
- lib
|
|
@@ -449,8 +467,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
449
467
|
- !ruby/object:Gem::Version
|
|
450
468
|
version: '0'
|
|
451
469
|
requirements: []
|
|
452
|
-
rubygems_version: 3.
|
|
453
|
-
signing_key:
|
|
470
|
+
rubygems_version: 3.0.3
|
|
471
|
+
signing_key:
|
|
454
472
|
specification_version: 4
|
|
455
473
|
summary: Gem for adding auction behavior to models.
|
|
456
474
|
test_files: []
|