auctify 1.1.3 → 1.1.4
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/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/sale/auction.rb +12 -1
- data/lib/auctify/railtie.rb +11 -0
- data/lib/auctify/version.rb +1 -1
- data/lib/auctify.rb +5 -0
- data/lib/yabeda_config.rb +16 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bff579c105985a8f250d586936aa3ff93dbf1d0fe3b378c69b1ca91cd54e8dbe
|
4
|
+
data.tar.gz: 40a062694ac56b79ff884ec3cb233c4647881d365f76fee944da6ba0c88ceee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aab916ea0865c95cb54199b7ad1d807f3508dd87c6e94cebb8eed533b5e7f79e9f5d58132f65cebc14a3a8fc096073794e5df443e883d17a57c37eacb849e9d6
|
7
|
+
data.tar.gz: 814db09ba82b44e8c59981f0f439d7e39d2fe8df85c13c057ae167c0488989de7b5512ddb0473529398a2d10ff5108afc2151e261d83ae6699c0f0b0f7571a31
|
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.
|
@@ -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
|
@@ -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))
|
73
75
|
self.currently_ends_at = now if now < currently_ends_at
|
74
76
|
|
75
77
|
after_close_bidding
|
@@ -161,7 +163,16 @@ module Auctify
|
|
161
163
|
|
162
164
|
bap = Auctify::BidsAppender.call(auction: self, bid: bid)
|
163
165
|
|
164
|
-
bap.success?
|
166
|
+
if bap.success?
|
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
|
175
|
+
|
165
176
|
bap.success?
|
166
177
|
end
|
167
178
|
end
|
data/lib/auctify/version.rb
CHANGED
data/lib/auctify.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yabeda/prometheus"
|
4
|
+
|
5
|
+
Yabeda.configure do
|
6
|
+
group :auctify do
|
7
|
+
counter :bids_count, comment: "A counter of applied bids"
|
8
|
+
gauge :diff_in_closing_time_seconds,
|
9
|
+
comment: "Difference between auction.currently_ends_at and actual sale end time by job"
|
10
|
+
gauge :time_between_bids, comment: "Time period between last two bids", tags: [:auction_slug]
|
11
|
+
end
|
12
|
+
|
13
|
+
collect do # when /metrics is displayed
|
14
|
+
# main_app.t_gauge.set({}, rand(10))
|
15
|
+
end
|
16
|
+
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- foton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-07 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
|
@@ -428,8 +442,10 @@ files:
|
|
428
442
|
- lib/auctify.rb
|
429
443
|
- lib/auctify/configuration.rb
|
430
444
|
- lib/auctify/engine.rb
|
445
|
+
- lib/auctify/railtie.rb
|
431
446
|
- lib/auctify/version.rb
|
432
447
|
- lib/tasks/auctify_tasks.rake
|
448
|
+
- lib/yabeda_config.rb
|
433
449
|
homepage: https://github.com/sinfin/auctify
|
434
450
|
licenses:
|
435
451
|
- MIT
|