auction_fun_core 0.8.5 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +2 -0
- data/CHANGELOG.md +48 -0
- data/Procfile +1 -0
- data/README.md +34 -32
- data/Rakefile +1 -1
- data/auction_fun_core.gemspec +1 -0
- data/db/migrate/20240229143000_create_auctions.rb +1 -0
- data/db/seeds.rb +87 -36
- data/i18n/en-US/contracts/contracts.en-US.yml +12 -0
- data/i18n/en-US/mail/application.en-US.yml +66 -0
- data/i18n/en-US/mail/auction_context/post_auction/participant.en-US.yml +13 -0
- data/i18n/en-US/mail/auction_context/post_auction/winner.en-US.yml +13 -0
- data/i18n/en-US/mail/auction_context/pre_auction/auction_start_reminder.en-US.yml +11 -0
- data/i18n/pt-BR/contracts/contracts.pt-BR.yml +12 -0
- data/i18n/pt-BR/mail/application.pt-BR.yml +66 -0
- data/i18n/pt-BR/mail/auction_context/post_auction/participant.pt-BR.yml +13 -0
- data/i18n/pt-BR/mail/auction_context/post_auction/winner.pt-BR.yml +13 -0
- data/i18n/pt-BR/mail/auction_context/pre_auction/auction_start_reminder.pt-BR.yml +11 -0
- data/i18n/pt-BR/mail/user_context/registration.pt-BR.yml +0 -4
- data/lib/auction_fun_core/business/configuration.rb +31 -0
- data/lib/auction_fun_core/business/token_generator.rb +19 -1
- data/lib/auction_fun_core/contracts/application_contract.rb +9 -1
- data/lib/auction_fun_core/contracts/auction_context/create_contract.rb +35 -20
- data/lib/auction_fun_core/contracts/auction_context/post_auction/participant_contract.rb +64 -0
- data/lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb +62 -0
- data/lib/auction_fun_core/contracts/auction_context/pre_auction/auction_start_reminder_contract.rb +48 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/closed_contract.rb +59 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb +60 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb +60 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/pause_contract.rb +16 -4
- data/lib/auction_fun_core/contracts/auction_context/processor/start_contract.rb +17 -5
- data/lib/auction_fun_core/contracts/auction_context/processor/unpause_contract.rb +16 -4
- data/lib/auction_fun_core/contracts/bid_context/create_bid_closed_contract.rb +20 -11
- data/lib/auction_fun_core/contracts/bid_context/create_bid_penny_contract.rb +18 -9
- data/lib/auction_fun_core/contracts/bid_context/create_bid_standard_contract.rb +19 -10
- data/lib/auction_fun_core/contracts/staff_context/authentication_contract.rb +18 -4
- data/lib/auction_fun_core/contracts/staff_context/registration_contract.rb +20 -8
- data/lib/auction_fun_core/contracts/user_context/authentication_contract.rb +18 -4
- data/lib/auction_fun_core/contracts/user_context/email_confirmation_contract.rb +17 -2
- data/lib/auction_fun_core/contracts/user_context/phone_confirmation_contract.rb +17 -2
- data/lib/auction_fun_core/contracts/user_context/registration_contract.rb +26 -8
- data/lib/auction_fun_core/entities/auction.rb +52 -2
- data/lib/auction_fun_core/entities/bid.rb +3 -2
- data/lib/auction_fun_core/entities/staff.rb +15 -2
- data/lib/auction_fun_core/entities/user.rb +31 -2
- data/lib/auction_fun_core/events/app.rb +8 -2
- data/lib/auction_fun_core/events/listener.rb +19 -16
- data/lib/auction_fun_core/operations/auction_context/create_operation.rb +37 -11
- data/lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb +85 -0
- data/lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb +85 -0
- data/lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb +96 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/closed_operation.rb +172 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb +171 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb +171 -0
- data/lib/auction_fun_core/operations/auction_context/processor/pause_operation.rb +36 -1
- data/lib/auction_fun_core/operations/auction_context/processor/start_operation.rb +23 -11
- data/lib/auction_fun_core/operations/auction_context/processor/unpause_operation.rb +36 -1
- data/lib/auction_fun_core/operations/bid_context/create_bid_penny_operation.rb +57 -7
- data/lib/auction_fun_core/operations/staff_context/registration_operation.rb +10 -0
- data/lib/auction_fun_core/relations/auctions.rb +252 -30
- data/lib/auction_fun_core/relations/bids.rb +18 -0
- data/lib/auction_fun_core/relations/staffs.rb +1 -1
- data/lib/auction_fun_core/repos/auction_context/auction_repository.rb +40 -11
- data/lib/auction_fun_core/repos/bid_context/bid_repository.rb +27 -5
- data/lib/auction_fun_core/repos/staff_context/staff_repository.rb +63 -21
- data/lib/auction_fun_core/repos/user_context/user_repository.rb +69 -25
- data/lib/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer.rb +37 -0
- data/lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb +37 -0
- data/lib/auction_fun_core/services/mail/auction_context/pre_auction/auction_start_reminder_mailer.rb +35 -0
- data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/participant.html.erb +173 -0
- data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb +174 -0
- data/lib/auction_fun_core/services/mail/templates/auction_context/pre_auction/auction_start_reminder.html.erb +192 -0
- data/lib/auction_fun_core/services/mail/templates/user_context/registration.html.erb +2 -2
- data/lib/auction_fun_core/services/mail/user_context/registration_mailer.rb +6 -0
- data/lib/auction_fun_core/version.rb +1 -1
- data/lib/auction_fun_core/workers/application_job.rb +12 -0
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb +38 -0
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb +37 -0
- data/lib/auction_fun_core/workers/operations/auction_context/pre_auction/auction_start_reminder_operation_job.rb +44 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job.rb +37 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb +40 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb +38 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/start_operation_job.rb +6 -3
- data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job.rb +56 -0
- data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb +57 -0
- data/lib/auction_fun_core/workers/services/mail/auction_context/pre_auction/auction_start_reminder_mailer_job.rb +48 -0
- data/lib/auction_fun_core/workers/services/mail/user_context/registration_mailer_job.rb +8 -6
- data/system/providers/background_job.rb +25 -0
- metadata +51 -5
- data/lib/auction_fun_core/contracts/auction_context/processor/finish_contract.rb +0 -27
- data/lib/auction_fun_core/operations/auction_context/processor/finish_operation.rb +0 -61
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish_operation_job.rb +0 -32
data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AuctionFunCore
|
4
|
+
module Workers
|
5
|
+
module Operations
|
6
|
+
module AuctionContext
|
7
|
+
module Processor
|
8
|
+
module Finish
|
9
|
+
##
|
10
|
+
# Background job class responsible for call finish penny auction operation.
|
11
|
+
class PennyOperationJob < Workers::ApplicationJob
|
12
|
+
include Sidekiq::Worker
|
13
|
+
include Import["repos.auction_context.auction_repository"]
|
14
|
+
include Import["operations.auction_context.processor.finish.penny_operation"]
|
15
|
+
|
16
|
+
sidekiq_options queue: "default", lock: :until_executed, on_conflict: :replace
|
17
|
+
|
18
|
+
# Executes the operation to finish a penny auction.
|
19
|
+
#
|
20
|
+
# @param auction_id [Integer] The ID of the penny auction.
|
21
|
+
# @param retry_count [Integer] The current retry count for the job.
|
22
|
+
# @return [void]
|
23
|
+
def perform(auction_id, retry_count = 0)
|
24
|
+
auction = auction_repository.by_id!(auction_id)
|
25
|
+
|
26
|
+
penny_operation.call(auction_id: auction.id)
|
27
|
+
rescue => e
|
28
|
+
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
29
|
+
raise if retry_count >= MAX_RETRIES
|
30
|
+
|
31
|
+
interval = backoff_exponential_job(retry_count)
|
32
|
+
self.class.perform_at(interval, auction_id, retry_count + 1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AuctionFunCore
|
4
|
+
module Workers
|
5
|
+
module Operations
|
6
|
+
module AuctionContext
|
7
|
+
module Processor
|
8
|
+
module Finish
|
9
|
+
##
|
10
|
+
# Background job class responsible for call finish standard auction operation.
|
11
|
+
#
|
12
|
+
class StandardOperationJob < Workers::ApplicationJob
|
13
|
+
include Import["repos.auction_context.auction_repository"]
|
14
|
+
include Import["operations.auction_context.processor.finish.standard_operation"]
|
15
|
+
|
16
|
+
# Executes the operation to finish a standard auction.
|
17
|
+
#
|
18
|
+
# @param auction_id [Integer] The ID of the standard auction.
|
19
|
+
# @param retry_count [Integer] The current retry count for the job.
|
20
|
+
# @return [void]
|
21
|
+
def perform(auction_id, retry_count = 0)
|
22
|
+
auction = auction_repository.by_id!(auction_id)
|
23
|
+
|
24
|
+
standard_operation.call(auction_id: auction.id)
|
25
|
+
rescue => e
|
26
|
+
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
27
|
+
raise if retry_count >= MAX_RETRIES
|
28
|
+
|
29
|
+
interval = backoff_exponential_job(retry_count)
|
30
|
+
self.class.perform_at(interval, auction_id, retry_count + 1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/auction_fun_core/workers/operations/auction_context/processor/start_operation_job.rb
CHANGED
@@ -6,13 +6,16 @@ module AuctionFunCore
|
|
6
6
|
module AuctionContext
|
7
7
|
module Processor
|
8
8
|
##
|
9
|
-
#
|
10
|
-
#
|
9
|
+
# Background job class responsible for call start auction operation.
|
11
10
|
class StartOperationJob < AuctionFunCore::Workers::ApplicationJob
|
12
11
|
include Import["repos.auction_context.auction_repository"]
|
13
12
|
include Import["operations.auction_context.processor.start_operation"]
|
14
13
|
|
15
|
-
#
|
14
|
+
# Executes the operation to start an auction.
|
15
|
+
#
|
16
|
+
# @param auction_id [Integer] The ID of the auction to start.
|
17
|
+
# @param retry_count [Integer] The current retry count for the job.
|
18
|
+
# @return [void]
|
16
19
|
def perform(auction_id, retry_count = 0)
|
17
20
|
auction = auction_repository.by_id!(auction_id)
|
18
21
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AuctionFunCore
|
4
|
+
module Workers
|
5
|
+
module Services
|
6
|
+
module Mail
|
7
|
+
module AuctionContext
|
8
|
+
module PostAuction
|
9
|
+
##
|
10
|
+
# Background job class responsible for queuing participant emails.
|
11
|
+
class ParticipantMailerJob < AuctionFunCore::Workers::ApplicationJob
|
12
|
+
include Import["repos.user_context.user_repository"]
|
13
|
+
include Import["repos.auction_context.auction_repository"]
|
14
|
+
|
15
|
+
# Reads the statistics of a participant in an auction and sends it by email.
|
16
|
+
#
|
17
|
+
# @param auction_id [Integer] The ID of the auction.
|
18
|
+
# @param participant_id [Integer] The ID of the participant.
|
19
|
+
# @param retry_count [Integer] The current retry count for the job.
|
20
|
+
# @return [void]
|
21
|
+
def perform(auction_id, participant_id, retry_count = 0)
|
22
|
+
auction = auction_repository.by_id!(auction_id)
|
23
|
+
participant = user_repository.by_id!(participant_id)
|
24
|
+
|
25
|
+
statistics = relation.load_participant_statistics.call(auction.id, participant.id).first
|
26
|
+
|
27
|
+
participant_mailer.new(auction, participant, statistics).deliver
|
28
|
+
rescue => e
|
29
|
+
capture_exception(e, {auction_id: auction_id, participant_id: participant_id, retry_count: retry_count})
|
30
|
+
raise e if retry_count >= MAX_RETRIES
|
31
|
+
|
32
|
+
interval = backoff_exponential_job(retry_count)
|
33
|
+
self.class.perform_at(interval, auction_id, participant_id, retry_count + 1)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Directly specifies the class to be called due to non-standard dependency injection.
|
39
|
+
# @return [Class] The participant mailer class.
|
40
|
+
def participant_mailer
|
41
|
+
AuctionFunCore::Services::Mail::AuctionContext::PostAuction::ParticipantMailer
|
42
|
+
end
|
43
|
+
|
44
|
+
# Retrieves the relation for loading participant statistics.
|
45
|
+
#
|
46
|
+
# @return [ROM::Relation] The relation object.
|
47
|
+
def relation
|
48
|
+
AuctionFunCore::Application[:container].relations[:auctions]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AuctionFunCore
|
4
|
+
module Workers
|
5
|
+
module Services
|
6
|
+
module Mail
|
7
|
+
module AuctionContext
|
8
|
+
module PostAuction
|
9
|
+
##
|
10
|
+
# Background job class responsible for adding emails to the queue.
|
11
|
+
#
|
12
|
+
class WinnerMailerJob < AuctionFunCore::Workers::ApplicationJob
|
13
|
+
include Import["repos.user_context.user_repository"]
|
14
|
+
include Import["repos.auction_context.auction_repository"]
|
15
|
+
|
16
|
+
# Reads the statistics of a winner in an auction and sends it by email.
|
17
|
+
#
|
18
|
+
# @param auction_id [Integer] The ID of the auction.
|
19
|
+
# @param winner_id [Integer] The ID of the winner.
|
20
|
+
# @param retry_count [Integer] The current retry count for the job.
|
21
|
+
# @return [void]
|
22
|
+
def perform(auction_id, winner_id, retry_count = 0)
|
23
|
+
auction = auction_repository.by_id!(auction_id)
|
24
|
+
winner = user_repository.by_id!(winner_id)
|
25
|
+
|
26
|
+
statistics = relation.load_winner_statistics.call(auction_id, winner_id).first
|
27
|
+
|
28
|
+
winner_mailer.new(auction, winner, statistics).deliver
|
29
|
+
rescue => e
|
30
|
+
capture_exception(e, {auction_id: auction_id, winner_id: winner_id, retry_count: retry_count})
|
31
|
+
raise e if retry_count >= MAX_RETRIES
|
32
|
+
|
33
|
+
interval = backoff_exponential_job(retry_count)
|
34
|
+
self.class.perform_at(interval, auction_id, winner_id, retry_count + 1)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Directly specifies the class to be called due to non-standard dependency injection.
|
40
|
+
# @return [Class] The winner mailer class.
|
41
|
+
def winner_mailer
|
42
|
+
AuctionFunCore::Services::Mail::AuctionContext::PostAuction::WinnerMailer
|
43
|
+
end
|
44
|
+
|
45
|
+
# Retrieves the relation for loading winner statistics.
|
46
|
+
#
|
47
|
+
# @return [ROM::Relation] The relation object.
|
48
|
+
def relation
|
49
|
+
AuctionFunCore::Application[:container].relations[:auctions]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AuctionFunCore
|
4
|
+
module Workers
|
5
|
+
module Services
|
6
|
+
module Mail
|
7
|
+
module AuctionContext
|
8
|
+
module PreAuction
|
9
|
+
##
|
10
|
+
# Background job class responsible for adding auction start emails to the queue.
|
11
|
+
class AuctionStartReminderMailerJob < AuctionFunCore::Workers::ApplicationJob
|
12
|
+
include Import["repos.user_context.user_repository"]
|
13
|
+
include Import["repos.auction_context.auction_repository"]
|
14
|
+
|
15
|
+
# Executes the operation of sending an email to the participant notifying
|
16
|
+
# them of the start of the auction.
|
17
|
+
#
|
18
|
+
# @param auction_id [Integer] The ID of the standard auction.
|
19
|
+
# @param participant_id [Integer] The ID of the participant
|
20
|
+
# @param retry_count [Integer] The current retry count for the job.
|
21
|
+
# @return [void]
|
22
|
+
def perform(auction_id, participant_id, retry_count = 0)
|
23
|
+
auction = auction_repository.by_id!(auction_id)
|
24
|
+
participant = user_repository.by_id!(participant_id)
|
25
|
+
|
26
|
+
auction_start_reminder_mailer.new(auction, participant).deliver
|
27
|
+
rescue => e
|
28
|
+
capture_exception(e, {auction_id: auction_id, participant_id: participant_id, retry_count: retry_count})
|
29
|
+
raise e if retry_count >= MAX_RETRIES
|
30
|
+
|
31
|
+
interval = backoff_exponential_job(retry_count)
|
32
|
+
self.class.perform_at(interval, auction_id, participant_id, retry_count + 1)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# Directly specifies the class to be called due to non-standard dependency injection.
|
38
|
+
# @return [Class] The auction start reminder mailer class.
|
39
|
+
def auction_start_reminder_mailer
|
40
|
+
AuctionFunCore::Services::Mail::AuctionContext::PreAuction::AuctionStartReminderMailer
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -6,12 +6,15 @@ module AuctionFunCore
|
|
6
6
|
module Mail
|
7
7
|
module UserContext
|
8
8
|
##
|
9
|
-
# Background job class responsible for
|
10
|
-
#
|
9
|
+
# Background job class responsible for queuing registration emails.
|
11
10
|
class RegistrationMailerJob < AuctionFunCore::Workers::ApplicationJob
|
12
11
|
include Import["repos.user_context.user_repository"]
|
13
12
|
|
14
|
-
#
|
13
|
+
# Initializes a new RegistrationMailerJob instance.
|
14
|
+
#
|
15
|
+
# @param user_id [Integer] The ID of the user.
|
16
|
+
# @param retry_count [Integer] The current retry count for the job.
|
17
|
+
# @return [void]
|
15
18
|
def perform(user_id, retry_count = 0)
|
16
19
|
user = user_repository.by_id!(user_id)
|
17
20
|
|
@@ -26,9 +29,8 @@ module AuctionFunCore
|
|
26
29
|
|
27
30
|
private
|
28
31
|
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# Therefore, here I directly explain the class to be called.
|
32
|
+
# Directly specifies the class to be called due to non-standard dependency injection.
|
33
|
+
# @return [Class] The registration mailer class.
|
32
34
|
def registration_mailer
|
33
35
|
AuctionFunCore::Services::Mail::UserContext::RegistrationMailer
|
34
36
|
end
|
@@ -3,13 +3,38 @@
|
|
3
3
|
AuctionFunCore::Application.register_provider(:background_job) do
|
4
4
|
prepare do
|
5
5
|
require "sidekiq"
|
6
|
+
require "sidekiq-unique-jobs"
|
6
7
|
end
|
7
8
|
|
8
9
|
start do
|
9
10
|
Sidekiq.configure_server do |config|
|
11
|
+
# Set up Sidekiq server configuration
|
12
|
+
config.redis = {url: target[:settings].redis_url}
|
10
13
|
config.logger = target[:settings].logger
|
11
14
|
config.average_scheduled_poll_interval = 3
|
15
|
+
|
16
|
+
# Configure client middleware for uniqueness
|
17
|
+
config.client_middleware do |chain|
|
18
|
+
chain.add SidekiqUniqueJobs::Middleware::Client
|
19
|
+
end
|
20
|
+
|
21
|
+
# Configure server middleware for uniqueness
|
22
|
+
config.server_middleware do |chain|
|
23
|
+
chain.add SidekiqUniqueJobs::Middleware::Server
|
24
|
+
end
|
25
|
+
|
26
|
+
# Configure Sidekiq Unique Jobs for the server
|
27
|
+
SidekiqUniqueJobs::Server.configure(config)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Configure client middleware for uniqueness
|
31
|
+
Sidekiq.configure_client do |config|
|
32
|
+
# Set up Sidekiq client configuration
|
12
33
|
config.redis = {url: target[:settings].redis_url}
|
34
|
+
|
35
|
+
config.client_middleware do |chain|
|
36
|
+
chain.add SidekiqUniqueJobs::Middleware::Client
|
37
|
+
end
|
13
38
|
end
|
14
39
|
end
|
15
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auction_fun_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - '='
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: 7.2.2
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: sidekiq-unique-jobs
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - '='
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 8.0.10
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - '='
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 8.0.10
|
237
251
|
- !ruby/object:Gem::Dependency
|
238
252
|
name: yard
|
239
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -295,8 +309,16 @@ files:
|
|
295
309
|
- db/migrate/20240304144422_create_bids.rb
|
296
310
|
- db/seeds.rb
|
297
311
|
- i18n/en-US/contracts/contracts.en-US.yml
|
312
|
+
- i18n/en-US/mail/application.en-US.yml
|
313
|
+
- i18n/en-US/mail/auction_context/post_auction/participant.en-US.yml
|
314
|
+
- i18n/en-US/mail/auction_context/post_auction/winner.en-US.yml
|
315
|
+
- i18n/en-US/mail/auction_context/pre_auction/auction_start_reminder.en-US.yml
|
298
316
|
- i18n/en-US/mail/user_context/registration.en-US.yml
|
299
317
|
- i18n/pt-BR/contracts/contracts.pt-BR.yml
|
318
|
+
- i18n/pt-BR/mail/application.pt-BR.yml
|
319
|
+
- i18n/pt-BR/mail/auction_context/post_auction/participant.pt-BR.yml
|
320
|
+
- i18n/pt-BR/mail/auction_context/post_auction/winner.pt-BR.yml
|
321
|
+
- i18n/pt-BR/mail/auction_context/pre_auction/auction_start_reminder.pt-BR.yml
|
300
322
|
- i18n/pt-BR/mail/user_context/registration.pt-BR.yml
|
301
323
|
- lib/auction_fun_core.rb
|
302
324
|
- lib/auction_fun_core/business/configuration.rb
|
@@ -311,7 +333,12 @@ files:
|
|
311
333
|
- lib/auction_fun_core/commands/user_context/create_user.rb
|
312
334
|
- lib/auction_fun_core/contracts/application_contract.rb
|
313
335
|
- lib/auction_fun_core/contracts/auction_context/create_contract.rb
|
314
|
-
- lib/auction_fun_core/contracts/auction_context/
|
336
|
+
- lib/auction_fun_core/contracts/auction_context/post_auction/participant_contract.rb
|
337
|
+
- lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb
|
338
|
+
- lib/auction_fun_core/contracts/auction_context/pre_auction/auction_start_reminder_contract.rb
|
339
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/closed_contract.rb
|
340
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb
|
341
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb
|
315
342
|
- lib/auction_fun_core/contracts/auction_context/processor/pause_contract.rb
|
316
343
|
- lib/auction_fun_core/contracts/auction_context/processor/start_contract.rb
|
317
344
|
- lib/auction_fun_core/contracts/auction_context/processor/unpause_contract.rb
|
@@ -331,7 +358,12 @@ files:
|
|
331
358
|
- lib/auction_fun_core/events/app.rb
|
332
359
|
- lib/auction_fun_core/events/listener.rb
|
333
360
|
- lib/auction_fun_core/operations/auction_context/create_operation.rb
|
334
|
-
- lib/auction_fun_core/operations/auction_context/
|
361
|
+
- lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb
|
362
|
+
- lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb
|
363
|
+
- lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb
|
364
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/closed_operation.rb
|
365
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb
|
366
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb
|
335
367
|
- lib/auction_fun_core/operations/auction_context/processor/pause_operation.rb
|
336
368
|
- lib/auction_fun_core/operations/auction_context/processor/start_operation.rb
|
337
369
|
- lib/auction_fun_core/operations/auction_context/processor/unpause_operation.rb
|
@@ -353,13 +385,27 @@ files:
|
|
353
385
|
- lib/auction_fun_core/repos/bid_context/bid_repository.rb
|
354
386
|
- lib/auction_fun_core/repos/staff_context/staff_repository.rb
|
355
387
|
- lib/auction_fun_core/repos/user_context/user_repository.rb
|
388
|
+
- lib/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer.rb
|
389
|
+
- lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb
|
390
|
+
- lib/auction_fun_core/services/mail/auction_context/pre_auction/auction_start_reminder_mailer.rb
|
391
|
+
- lib/auction_fun_core/services/mail/templates/auction_context/post_auction/participant.html.erb
|
392
|
+
- lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb
|
393
|
+
- lib/auction_fun_core/services/mail/templates/auction_context/pre_auction/auction_start_reminder.html.erb
|
356
394
|
- lib/auction_fun_core/services/mail/templates/layout.html.erb
|
357
395
|
- lib/auction_fun_core/services/mail/templates/user_context/registration.html.erb
|
358
396
|
- lib/auction_fun_core/services/mail/user_context/registration_mailer.rb
|
359
397
|
- lib/auction_fun_core/version.rb
|
360
398
|
- lib/auction_fun_core/workers/application_job.rb
|
361
|
-
- lib/auction_fun_core/workers/operations/auction_context/
|
399
|
+
- lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb
|
400
|
+
- lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb
|
401
|
+
- lib/auction_fun_core/workers/operations/auction_context/pre_auction/auction_start_reminder_operation_job.rb
|
402
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job.rb
|
403
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb
|
404
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb
|
362
405
|
- lib/auction_fun_core/workers/operations/auction_context/processor/start_operation_job.rb
|
406
|
+
- lib/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job.rb
|
407
|
+
- lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb
|
408
|
+
- lib/auction_fun_core/workers/services/mail/auction_context/pre_auction/auction_start_reminder_mailer_job.rb
|
363
409
|
- lib/auction_fun_core/workers/services/mail/user_context/registration_mailer_job.rb
|
364
410
|
- lib/tasks/database.rake
|
365
411
|
- system/providers/background_job.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module AuctionFunCore
|
4
|
-
module Contracts
|
5
|
-
module AuctionContext
|
6
|
-
module Processor
|
7
|
-
##
|
8
|
-
# Contract class for finish auctions.
|
9
|
-
#
|
10
|
-
class FinishContract < Contracts::ApplicationContract
|
11
|
-
option :auction_repo, default: proc { Repos::AuctionContext::AuctionRepository.new }
|
12
|
-
|
13
|
-
params do
|
14
|
-
required(:auction_id).filled(:integer)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Validation for auction.
|
18
|
-
# Validates if the auction exists in the database.
|
19
|
-
rule(:auction_id) do |context:|
|
20
|
-
context[:auction] ||= auction_repo.by_id(value)
|
21
|
-
key.failure(I18n.t("contracts.errors.custom.not_found")) unless context[:auction]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module AuctionFunCore
|
4
|
-
module Operations
|
5
|
-
module AuctionContext
|
6
|
-
module Processor
|
7
|
-
##
|
8
|
-
# Operation class for dispatch finish auction.
|
9
|
-
# By default, this change auction status from 'running' to 'finished'.
|
10
|
-
#
|
11
|
-
class FinishOperation < AuctionFunCore::Operations::Base
|
12
|
-
include Import["repos.auction_context.auction_repository"]
|
13
|
-
include Import["contracts.auction_context.processor.finish_contract"]
|
14
|
-
|
15
|
-
# @todo Add custom doc
|
16
|
-
def self.call(auction_id, &block)
|
17
|
-
operation = new.call(auction_id)
|
18
|
-
|
19
|
-
return operation unless block
|
20
|
-
|
21
|
-
Dry::Matcher::ResultMatcher.call(operation, &block)
|
22
|
-
end
|
23
|
-
|
24
|
-
# It only performs the basic processing of completing an auction.
|
25
|
-
# It just changes the status at the database level and triggers the finished event.
|
26
|
-
# @param auction_id [Integer] Auction ID
|
27
|
-
# @return [Dry::Monads::Result::Success, Dry::Monads::Result::Failure]
|
28
|
-
def call(auction_id)
|
29
|
-
yield validate(auction_id: auction_id)
|
30
|
-
|
31
|
-
auction_repository.transaction do |_t|
|
32
|
-
@auction, _ = auction_repository.update(auction_id, status: "finished")
|
33
|
-
|
34
|
-
publish_auction_finish_event(@auction)
|
35
|
-
end
|
36
|
-
|
37
|
-
Success(@auction)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
# Calls the finish contract class to perform the validation
|
43
|
-
# of the informed attributes.
|
44
|
-
# @param attributes [Hash] auction attributes
|
45
|
-
# @return [Dry::Monads::Result::Success, Dry::Monads::Result::Failure]
|
46
|
-
def validate(attributes)
|
47
|
-
contract = finish_contract.call(attributes)
|
48
|
-
|
49
|
-
return Failure(contract.errors.to_h) if contract.failure?
|
50
|
-
|
51
|
-
Success(contract.to_h)
|
52
|
-
end
|
53
|
-
|
54
|
-
def publish_auction_finish_event(auction)
|
55
|
-
Application[:event].publish("auctions.finished", auction.to_h)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/auction_fun_core/workers/operations/auction_context/processor/finish_operation_job.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module AuctionFunCore
|
4
|
-
module Workers
|
5
|
-
module Operations
|
6
|
-
module AuctionContext
|
7
|
-
module Processor
|
8
|
-
##
|
9
|
-
# BackgroundJob class for call finish auction operation.
|
10
|
-
#
|
11
|
-
class FinishOperationJob < Workers::ApplicationJob
|
12
|
-
include Import["repos.auction_context.auction_repository"]
|
13
|
-
include Import["operations.auction_context.processor.finish_operation"]
|
14
|
-
|
15
|
-
# @todo Add detailed documentation
|
16
|
-
def perform(auction_id, retry_count = 0)
|
17
|
-
auction = auction_repository.by_id!(auction_id)
|
18
|
-
|
19
|
-
finish_operation.call(auction.id)
|
20
|
-
rescue => e
|
21
|
-
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
22
|
-
raise if retry_count >= MAX_RETRIES
|
23
|
-
|
24
|
-
interval = backoff_exponential_job(retry_count)
|
25
|
-
self.class.perform_at(interval, auction_id, retry_count + 1)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|