auction_fun_core 0.8.7 → 0.8.9
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/.standard.yml +2 -0
- data/CHANGELOG.md +23 -0
- data/Procfile +1 -0
- data/README.md +34 -32
- data/Rakefile +1 -1
- data/i18n/en-US/contracts/contracts.en-US.yml +3 -0
- data/i18n/en-US/mail/application.en-US.yml +7 -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 +3 -0
- data/i18n/pt-BR/mail/application.pt-BR.yml +7 -0
- data/i18n/pt-BR/mail/auction_context/pre_auction/auction_start_reminder.pt-BR.yml +11 -0
- 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 +23 -1
- data/lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb +22 -1
- 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 +19 -7
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb +19 -7
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb +19 -7
- 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 +48 -4
- 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 +25 -9
- data/lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb +36 -3
- data/lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb +36 -2
- 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 +82 -10
- data/lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb +81 -10
- data/lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb +81 -12
- data/lib/auction_fun_core/operations/auction_context/processor/pause_operation.rb +36 -1
- data/lib/auction_fun_core/operations/auction_context/processor/unpause_operation.rb +36 -1
- data/lib/auction_fun_core/relations/auctions.rb +178 -97
- data/lib/auction_fun_core/relations/bids.rb +18 -0
- 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 +7 -1
- data/lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb +7 -1
- 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 +1 -1
- data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb +1 -1
- 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/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 +10 -0
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb +7 -2
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb +6 -2
- 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 +6 -3
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb +6 -3
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb +6 -2
- 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 +12 -7
- data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb +11 -5
- 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 +6 -0
- metadata +10 -2
|
@@ -3,7 +3,41 @@
|
|
|
3
3
|
module AuctionFunCore
|
|
4
4
|
module Repos
|
|
5
5
|
module StaffContext
|
|
6
|
-
#
|
|
6
|
+
# Repository for handling repository operations related to staffs.
|
|
7
|
+
#
|
|
8
|
+
# This repository provides methods to interact with staff data in the database,
|
|
9
|
+
# including creating, updating, deleting, and retrieving staffs.
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# staff_repo = AuctionFunCore::Repos::StaffContext::StaffRepository.new
|
|
13
|
+
#
|
|
14
|
+
# # Retrieve all staffs
|
|
15
|
+
# all_staffs = staff_repo.all
|
|
16
|
+
#
|
|
17
|
+
# # Get the total number of staffs
|
|
18
|
+
# total_staffs = staff_repo.count
|
|
19
|
+
#
|
|
20
|
+
# # Search staffs based on certain conditions
|
|
21
|
+
# conditions = {name: 'Staff'}
|
|
22
|
+
# search = staff_repo.query(conditions)
|
|
23
|
+
#
|
|
24
|
+
# # Find an staff by its ID
|
|
25
|
+
# staff = staff_repo.by_id(123)
|
|
26
|
+
#
|
|
27
|
+
# # Find an staff by its ID and raise an error if not found
|
|
28
|
+
# staff = staff_repo.by_id!(123)
|
|
29
|
+
#
|
|
30
|
+
# # Search for a staff by email or phone
|
|
31
|
+
# staff_by_login = staff_repo.by_login('example@example.com')
|
|
32
|
+
#
|
|
33
|
+
# # Check if a staff exists based on certain conditions
|
|
34
|
+
# conditions = { name: 'John Doe' }
|
|
35
|
+
# staff_exists = staff_repo.exists?(conditions)
|
|
36
|
+
#
|
|
37
|
+
# @see AuctionFunCore::Entities::Staff Struct representing staff data
|
|
38
|
+
# @see https://rom-rb.org/learn/sql/3.3/queries/
|
|
39
|
+
# @see https://api.rom-rb.org/rom-sql/ROM/SQL/Relation/Reading
|
|
40
|
+
#
|
|
7
41
|
class StaffRepository < ROM::Repository[:staffs]
|
|
8
42
|
include Import["container"]
|
|
9
43
|
|
|
@@ -11,50 +45,58 @@ module AuctionFunCore
|
|
|
11
45
|
commands :create, update: :by_pk, delete: :by_pk
|
|
12
46
|
|
|
13
47
|
# Returns all staffs in database.
|
|
14
|
-
# @return [Array<ROM::Struct::Staff
|
|
48
|
+
# @return [Array<ROM::Struct::Staff>]
|
|
15
49
|
def all
|
|
16
50
|
staffs.to_a
|
|
17
51
|
end
|
|
18
52
|
|
|
19
|
-
# Returns the total number of staffs in database.
|
|
20
|
-
#
|
|
53
|
+
# Returns the total number of staffs in the database.
|
|
54
|
+
#
|
|
55
|
+
# @return [Integer] Total number of staffs.
|
|
21
56
|
def count
|
|
22
57
|
staffs.count
|
|
23
58
|
end
|
|
24
59
|
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
# @
|
|
60
|
+
# Constructs SQL conditions for querying staffs in the database.
|
|
61
|
+
#
|
|
62
|
+
# @param conditions [Hash] The conditions to be used in the query (DSL Dataset).
|
|
63
|
+
# @return [AuctionFunCore::Relations::Staff] The relation containing the staffs that match the given conditions.
|
|
28
64
|
def query(conditions)
|
|
29
65
|
staffs.where(conditions)
|
|
30
66
|
end
|
|
31
67
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# @
|
|
68
|
+
# Retrieves an staff from the database by its primary key.
|
|
69
|
+
#
|
|
70
|
+
# @param id [Integer] The ID of the staff to retrieve.
|
|
71
|
+
# @return [ROM::Struct::Staff, nil] The retrieved staff, or nil if not found.
|
|
72
|
+
#
|
|
35
73
|
def by_id(id)
|
|
36
74
|
staffs.by_pk(id).one
|
|
37
75
|
end
|
|
38
76
|
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
# @
|
|
42
|
-
# @
|
|
77
|
+
# Retrieves an staff from the database by its primary key, raising an error if not found.
|
|
78
|
+
#
|
|
79
|
+
# @param id [Integer] The ID of the staff to retrieve.
|
|
80
|
+
# @raise [ROM::TupleCountMismatchError] if the staff is not found.
|
|
81
|
+
# @return [ROM::Struct::Staff] The retrieved staff.
|
|
82
|
+
#
|
|
43
83
|
def by_id!(id)
|
|
44
84
|
staffs.by_pk(id).one!
|
|
45
85
|
end
|
|
46
86
|
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# @
|
|
87
|
+
# Searches for a staff in the database by email or phone keys.
|
|
88
|
+
#
|
|
89
|
+
# @param login [String] The email or phone of the staff.
|
|
90
|
+
# @return [ROM::Struct::Staff, nil] The staff found with the provided email or phone,
|
|
91
|
+
# or nil if not found.
|
|
50
92
|
def by_login(login)
|
|
51
93
|
staffs.where(Sequel[email: login] | Sequel[phone: login]).one
|
|
52
94
|
end
|
|
53
95
|
|
|
54
|
-
# Checks if
|
|
55
|
-
#
|
|
56
|
-
# @
|
|
57
|
-
# @return [
|
|
96
|
+
# Checks if a bid exists based on the provided conditions.
|
|
97
|
+
#
|
|
98
|
+
# @param conditions [Hash] The conditions to check (DSL Dataset).
|
|
99
|
+
# @return [Boolean] true if a staff exists that matches the conditions, otherwise false.
|
|
58
100
|
def exists?(conditions)
|
|
59
101
|
staffs.exist?(conditions)
|
|
60
102
|
end
|
|
@@ -3,7 +3,40 @@
|
|
|
3
3
|
module AuctionFunCore
|
|
4
4
|
module Repos
|
|
5
5
|
module UserContext
|
|
6
|
-
#
|
|
6
|
+
# Repository for handling repository operations related to users.
|
|
7
|
+
#
|
|
8
|
+
# This repository provides methods to interact with user data in the database,
|
|
9
|
+
# including creating, updating, deleting, and retrieving users.
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# user_repo = AuctionFunCore::Repos::UserContext::UserRepository.new
|
|
13
|
+
#
|
|
14
|
+
# # Retrieve all users
|
|
15
|
+
# all_users = user_repo.all
|
|
16
|
+
#
|
|
17
|
+
# # Get the total number of users
|
|
18
|
+
# total_users = user_repo.count
|
|
19
|
+
#
|
|
20
|
+
# # Find a user by its ID
|
|
21
|
+
# user = user_repo.by_id(123)
|
|
22
|
+
#
|
|
23
|
+
# # Find a user by its ID and raise an error if not found
|
|
24
|
+
# user = user_repo.by_id!(123)
|
|
25
|
+
#
|
|
26
|
+
# # Search for a user by email or phone
|
|
27
|
+
# user = user_repo.by_login('example@example.com')
|
|
28
|
+
# user = user_repo.by_login('1234567890')
|
|
29
|
+
#
|
|
30
|
+
# # Search for a user by email confirmation token
|
|
31
|
+
# user = user_repo.by_email_confirmation_token('email_confirmation_token')
|
|
32
|
+
#
|
|
33
|
+
# # Search for a user by phone confirmation token
|
|
34
|
+
# user = user_repo.by_phone_confirmation_token('phone_confirmation_token')
|
|
35
|
+
#
|
|
36
|
+
# @see AuctionFunCore::Entities::User Struct representing user data
|
|
37
|
+
# @see https://rom-rb.org/learn/sql/3.3/queries/
|
|
38
|
+
# @see https://api.rom-rb.org/rom-sql/ROM/SQL/Relation/Reading
|
|
39
|
+
#
|
|
7
40
|
class UserRepository < ROM::Repository[:users]
|
|
8
41
|
include Import["container"]
|
|
9
42
|
|
|
@@ -11,7 +44,7 @@ module AuctionFunCore
|
|
|
11
44
|
commands :create, update: :by_pk, delete: :by_pk
|
|
12
45
|
|
|
13
46
|
# Returns all users in database.
|
|
14
|
-
# @return [Array<ROM::Struct::User
|
|
47
|
+
# @return [Array<ROM::Struct::User>]
|
|
15
48
|
def all
|
|
16
49
|
users.to_a
|
|
17
50
|
end
|
|
@@ -22,53 +55,64 @@ module AuctionFunCore
|
|
|
22
55
|
users.count
|
|
23
56
|
end
|
|
24
57
|
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
# @
|
|
58
|
+
# Constructs SQL conditions for querying users in the database.
|
|
59
|
+
#
|
|
60
|
+
# @param conditions [Hash] The conditions to be used in the query (DSL Dataset).
|
|
61
|
+
# @return [AuctionFunCore::Relations::Users] The relation containing the users that match the given conditions.
|
|
28
62
|
def query(conditions)
|
|
29
63
|
users.where(conditions)
|
|
30
64
|
end
|
|
31
65
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# @
|
|
66
|
+
# Retrieves a user from the database by its primary key.
|
|
67
|
+
#
|
|
68
|
+
# @param id [Integer] The ID of the user to retrieve.
|
|
69
|
+
# @return [ROM::Struct::User, nil] The retrieved user, or nil if not found.
|
|
70
|
+
#
|
|
35
71
|
def by_id(id)
|
|
36
72
|
users.by_pk(id).one
|
|
37
73
|
end
|
|
38
74
|
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
# @
|
|
42
|
-
# @
|
|
75
|
+
# Retrieves a user from the database by its primary key, raising an error if not found.
|
|
76
|
+
#
|
|
77
|
+
# @param id [Integer] The ID of the user to retrieve.
|
|
78
|
+
# @raise [ROM::TupleCountMismatchError] if the user is not found.
|
|
79
|
+
# @return [ROM::Struct::User] The retrieved user.
|
|
80
|
+
#
|
|
43
81
|
def by_id!(id)
|
|
44
82
|
users.by_pk(id).one!
|
|
45
83
|
end
|
|
46
84
|
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# @
|
|
85
|
+
# Searches for a user in the database by email or phone keys.
|
|
86
|
+
#
|
|
87
|
+
# @param login [String] The email or phone of the user.
|
|
88
|
+
# @return [ROM::Struct::User, nil] The user found with the provided email or phone,
|
|
89
|
+
# or nil if not found.
|
|
50
90
|
def by_login(login)
|
|
51
91
|
users.where(Sequel[email: login] | Sequel[phone: login]).one
|
|
52
92
|
end
|
|
53
93
|
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
# @
|
|
94
|
+
# Searches for a user in the database by email confirmation token.
|
|
95
|
+
#
|
|
96
|
+
# @param email_confirmation_token [String] The email confirmation token of the user.
|
|
97
|
+
# @return [ROM::Struct::User, nil] The user found with the provided email confirmation token,
|
|
98
|
+
# or nil if not found.
|
|
57
99
|
def by_email_confirmation_token(email_confirmation_token)
|
|
58
100
|
users.where(Sequel[email_confirmation_token: email_confirmation_token]).one
|
|
59
101
|
end
|
|
60
102
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
# @
|
|
103
|
+
# Searches for a user in the database by phone confirmation token.
|
|
104
|
+
#
|
|
105
|
+
# @param phone_confirmation_token [String] The phone confirmation token of the user.
|
|
106
|
+
# @return [ROM::Struct::User, nil] The user found with the provided phone confirmation token,
|
|
107
|
+
# or nil if not found.
|
|
64
108
|
def by_phone_confirmation_token(phone_confirmation_token)
|
|
65
109
|
users.where(Sequel[phone_confirmation_token: phone_confirmation_token]).one
|
|
66
110
|
end
|
|
67
111
|
|
|
68
|
-
# Checks if
|
|
69
|
-
#
|
|
70
|
-
# @
|
|
71
|
-
# @return [
|
|
112
|
+
# Checks if a user exists based on the provided conditions.
|
|
113
|
+
#
|
|
114
|
+
# @param conditions [Hash] The conditions to check (DSL Dataset).
|
|
115
|
+
# @return [Boolean] true if a user exists that matches the conditions, otherwise false.
|
|
72
116
|
def exists?(conditions)
|
|
73
117
|
users.exist?(conditions)
|
|
74
118
|
end
|
|
@@ -5,12 +5,15 @@ module AuctionFunCore
|
|
|
5
5
|
module Mail
|
|
6
6
|
module AuctionContext
|
|
7
7
|
module PostAuction
|
|
8
|
+
# Service class responsible for sending emails to auction participants.
|
|
8
9
|
class ParticipantMailer
|
|
9
10
|
include IdleMailer::Mailer
|
|
10
11
|
include IdleMailer::TemplateManager
|
|
11
12
|
|
|
13
|
+
# Initializes a new ParticipantMailer instance.
|
|
14
|
+
#
|
|
12
15
|
# @param auction [ROM::Struct::Auction] The auction object
|
|
13
|
-
# @param participant [ROM::Struct::User] The
|
|
16
|
+
# @param participant [ROM::Struct::User] The participant object
|
|
14
17
|
# @param statistics [OpenStruct] Statistics object
|
|
15
18
|
def initialize(auction, participant, statistics)
|
|
16
19
|
@auction = auction
|
|
@@ -20,6 +23,9 @@ module AuctionFunCore
|
|
|
20
23
|
mail.subject = I18n.t("mail.auction_context.post_auction.participant_mailer.subject", title: @auction.title)
|
|
21
24
|
end
|
|
22
25
|
|
|
26
|
+
# Returns the template name for the ParticipantMailer.
|
|
27
|
+
#
|
|
28
|
+
# @return [String] The template name.
|
|
23
29
|
def self.template_name
|
|
24
30
|
IdleMailer.config.templates.join("auction_context/post_auction/participant")
|
|
25
31
|
end
|
|
@@ -5,12 +5,15 @@ module AuctionFunCore
|
|
|
5
5
|
module Mail
|
|
6
6
|
module AuctionContext
|
|
7
7
|
module PostAuction
|
|
8
|
+
# Service class responsible for sending emails to auction winners.
|
|
8
9
|
class WinnerMailer
|
|
9
10
|
include IdleMailer::Mailer
|
|
10
11
|
include IdleMailer::TemplateManager
|
|
11
12
|
|
|
13
|
+
# Initializes a new WinnerMailer instance.
|
|
14
|
+
#
|
|
12
15
|
# @param auction [ROM::Struct::Auction] The auction object
|
|
13
|
-
# @param winner [ROM::Struct::User] The
|
|
16
|
+
# @param winner [ROM::Struct::User] The winner object
|
|
14
17
|
# @param statistics [OpenStruct] Statistics object
|
|
15
18
|
def initialize(auction, winner, statistics)
|
|
16
19
|
@auction = auction
|
|
@@ -20,6 +23,9 @@ module AuctionFunCore
|
|
|
20
23
|
mail.subject = I18n.t("mail.auction_context.post_auction.winner_mailer.subject", title: @auction.title)
|
|
21
24
|
end
|
|
22
25
|
|
|
26
|
+
# Returns the template name for the WinnerMailer.
|
|
27
|
+
#
|
|
28
|
+
# @return [String] The template name.
|
|
23
29
|
def self.template_name
|
|
24
30
|
IdleMailer.config.templates.join("auction_context/post_auction/winner")
|
|
25
31
|
end
|
data/lib/auction_fun_core/services/mail/auction_context/pre_auction/auction_start_reminder_mailer.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AuctionFunCore
|
|
4
|
+
module Services
|
|
5
|
+
module Mail
|
|
6
|
+
module AuctionContext
|
|
7
|
+
module PreAuction
|
|
8
|
+
# # Service class responsible for sending auction start reminder emails to participants.
|
|
9
|
+
class AuctionStartReminderMailer
|
|
10
|
+
include IdleMailer::Mailer
|
|
11
|
+
include IdleMailer::TemplateManager
|
|
12
|
+
|
|
13
|
+
# Initializes a new AuctionStartReminderMailer instance.
|
|
14
|
+
#
|
|
15
|
+
# @param auction [ROM::Struct::Auction] The auction object
|
|
16
|
+
# @param participant [ROM::Struct::User] The participant object
|
|
17
|
+
def initialize(auction, participant)
|
|
18
|
+
@auction = auction
|
|
19
|
+
@participant = participant
|
|
20
|
+
mail.to = participant.email
|
|
21
|
+
mail.subject = I18n.t("mail.auction_context.pre_auction.auction_start_reminder_mailer.subject", title: @auction.title)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns the template name for the AuctionStartReminderMailer.
|
|
25
|
+
#
|
|
26
|
+
# @return [String] The template name.
|
|
27
|
+
def self.template_name
|
|
28
|
+
IdleMailer.config.templates.join("auction_context/pre_auction/auction_start_reminder")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/participant.html.erb
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
30
30
|
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#434245;">
|
|
31
31
|
<h1 style="margin: 0; font-size: 24px; line-height: normal; font-weight: bold;">
|
|
32
|
-
<%= I18n.t("
|
|
32
|
+
<%= I18n.t("application.general.hello", name: @participant.name) %>,
|
|
33
33
|
</h1>
|
|
34
34
|
</div>
|
|
35
35
|
</td>
|
data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
30
30
|
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#434245;">
|
|
31
31
|
<h1 style="margin: 0; font-size: 24px; line-height: normal; font-weight: bold;">
|
|
32
|
-
<%= I18n.t("
|
|
32
|
+
<%= I18n.t("application.general.hello", name: @winner.name) %>,
|
|
33
33
|
</h1>
|
|
34
34
|
</div>
|
|
35
35
|
</td>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0" style="width:600px;" width="600">
|
|
2
|
+
<tr>
|
|
3
|
+
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
|
4
|
+
<div style="margin:0px auto;max-width:600px;">
|
|
5
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
|
|
6
|
+
<tbody>
|
|
7
|
+
<tr>
|
|
8
|
+
<td style="direction:ltr;font-size:0px;padding:20px 0;padding-bottom:0px;text-align:center;">
|
|
9
|
+
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
|
10
|
+
<tr>
|
|
11
|
+
<td style="vertical-align:top;width:600px;">
|
|
12
|
+
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
|
13
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
|
14
|
+
<tbody>
|
|
15
|
+
<tr>
|
|
16
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
17
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
|
|
18
|
+
<tbody>
|
|
19
|
+
<tr>
|
|
20
|
+
<td style="width:50px;">
|
|
21
|
+
<img alt="image description" height="auto" src="https://codedmails.com/images/logo-circle.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;font-size:14px;" width="50" />
|
|
22
|
+
</td>
|
|
23
|
+
</tr>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
</td>
|
|
27
|
+
</tr>
|
|
28
|
+
<tr>
|
|
29
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
30
|
+
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#434245;">
|
|
31
|
+
<h1 style="margin: 0; font-size: 24px; line-height: normal; font-weight: bold;">
|
|
32
|
+
<%= I18n.t("application.general.hello", name: @participant.name) %>,
|
|
33
|
+
</h1>
|
|
34
|
+
</div>
|
|
35
|
+
</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
</div>
|
|
40
|
+
</td>
|
|
41
|
+
</tr>
|
|
42
|
+
</table>
|
|
43
|
+
</td>
|
|
44
|
+
</tr>
|
|
45
|
+
</tbody>
|
|
46
|
+
</table>
|
|
47
|
+
</div>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
</table>
|
|
51
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0" style="width:600px;" width="600">
|
|
52
|
+
<tr>
|
|
53
|
+
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
|
|
54
|
+
<div style="margin:0px auto;max-width:600px;">
|
|
55
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;">
|
|
59
|
+
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
|
60
|
+
<tr>
|
|
61
|
+
<td style="vertical-align:top;width:600px;">
|
|
62
|
+
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
|
63
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
|
64
|
+
<tbody>
|
|
65
|
+
<tr>
|
|
66
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
67
|
+
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#434245;">
|
|
68
|
+
<%= raw I18n.t("mail.auction_context.pre_auction.auction_start_reminder_mailer.body.description") %>
|
|
69
|
+
</div>
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
<tr>
|
|
73
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
74
|
+
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#434245;">
|
|
75
|
+
<ul>
|
|
76
|
+
<li><%= I18n.t("mail.auction_context.pre_auction.auction_start_reminder_mailer.body.auction_date") %>: <%= I18n.l(@auction.started_at, format: :long) %></li>
|
|
77
|
+
</ul>
|
|
78
|
+
</td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td align="center" vertical-align="middle" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
82
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
|
|
83
|
+
<tbody>
|
|
84
|
+
<tr>
|
|
85
|
+
<td align="center" bgcolor="#2e58ff" role="presentation" style="border:none;border-radius:3px;cursor:auto;mso-padding-alt:10px 25px;background:#2e58ff;" valign="middle">
|
|
86
|
+
<a href="#" style="display: inline-block; background: #2e58ff; color: white; font-family: Roboto, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: normal; line-height: 30px; margin: 0; text-decoration: none; text-transform: none; padding: 10px
|
|
87
|
+
25px; mso-padding-alt: 0px; border-radius: 3px;" target="_blank"> <%= I18n.t("mail.auction_context.pre_auction.auction_start_reminder_mailer.body.link_to_auction") %> </a>
|
|
88
|
+
</td>
|
|
89
|
+
</tr>
|
|
90
|
+
</tbody>
|
|
91
|
+
</table>
|
|
92
|
+
</td>
|
|
93
|
+
</tr>
|
|
94
|
+
<tr>
|
|
95
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
96
|
+
<div style="font-family:Roboto, Helvetica, Arial, sans-serif;font-size:14px;font-weight:400;line-height:20px;text-align:left;color:#ffffff;">
|
|
97
|
+
<p style="margin-bottom: 0;"><%= I18n.t("mail.auction_context.pre_auction.auction_start_reminder_mailer.body.thanks") %></p>
|
|
98
|
+
</div>
|
|
99
|
+
</td>
|
|
100
|
+
</tr>
|
|
101
|
+
<tr>
|
|
102
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
103
|
+
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:bold;line-height:24px;text-align:left;color:#434245;">
|
|
104
|
+
<%= I18n.t("application.general.team") %>
|
|
105
|
+
</div>
|
|
106
|
+
</td>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
110
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation">
|
|
111
|
+
<tr>
|
|
112
|
+
<td>
|
|
113
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
114
|
+
<tbody>
|
|
115
|
+
<tr>
|
|
116
|
+
<td style="padding:4px;">
|
|
117
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
118
|
+
<tbody>
|
|
119
|
+
<tr>
|
|
120
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
121
|
+
<a href="https://twitter.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
122
|
+
<img alt="twitter-logo" height="18" src="https://codedmails.com/images/social/black/twitter-logo-transparent-black.png" style="border-radius:3px;display:block;" width="18" />
|
|
123
|
+
</a>
|
|
124
|
+
</td>
|
|
125
|
+
</tr>
|
|
126
|
+
</tbody>
|
|
127
|
+
</table>
|
|
128
|
+
</td>
|
|
129
|
+
</tr>
|
|
130
|
+
</tbody>
|
|
131
|
+
</table>
|
|
132
|
+
</td>
|
|
133
|
+
<td>
|
|
134
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
135
|
+
<tbody>
|
|
136
|
+
<tr>
|
|
137
|
+
<td style="padding:4px;">
|
|
138
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
139
|
+
<tbody>
|
|
140
|
+
<tr>
|
|
141
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
142
|
+
<a href="https://facebook.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
143
|
+
<img alt="facebook-logo" height="18" src="https://codedmails.com/images/social/black/facebook-logo-transparent-black.png" style="border-radius:3px;display:block;" width="18" />
|
|
144
|
+
</a>
|
|
145
|
+
</td>
|
|
146
|
+
</tr>
|
|
147
|
+
</tbody>
|
|
148
|
+
</table>
|
|
149
|
+
</td>
|
|
150
|
+
</tr>
|
|
151
|
+
</tbody>
|
|
152
|
+
</table>
|
|
153
|
+
</td>
|
|
154
|
+
<td>
|
|
155
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
156
|
+
<tbody>
|
|
157
|
+
<tr>
|
|
158
|
+
<td style="padding:4px;">
|
|
159
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
160
|
+
<tbody>
|
|
161
|
+
<tr>
|
|
162
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
163
|
+
<a href="https://instagram.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
164
|
+
<img alt="instagram-logo" height="18" src="https://codedmails.com/images/social/black/instagram-logo-transparent-black.png" style="border-radius:3px;display:block;" width="18" />
|
|
165
|
+
</a>
|
|
166
|
+
</td>
|
|
167
|
+
</tr>
|
|
168
|
+
</tbody>
|
|
169
|
+
</table>
|
|
170
|
+
</td>
|
|
171
|
+
</tr>
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>
|
|
174
|
+
</td>
|
|
175
|
+
</tr>
|
|
176
|
+
</table>
|
|
177
|
+
</td>
|
|
178
|
+
</tr>
|
|
179
|
+
</tbody>
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
</td>
|
|
183
|
+
</tr>
|
|
184
|
+
</table>
|
|
185
|
+
</td>
|
|
186
|
+
</tr>
|
|
187
|
+
</tbody>
|
|
188
|
+
</table>
|
|
189
|
+
</div>
|
|
190
|
+
</td>
|
|
191
|
+
</tr>
|
|
192
|
+
</table>
|
|
@@ -4,10 +4,13 @@ module AuctionFunCore
|
|
|
4
4
|
module Services
|
|
5
5
|
module Mail
|
|
6
6
|
module UserContext
|
|
7
|
+
# Service class responsible for sending registration emails to users.
|
|
7
8
|
class RegistrationMailer
|
|
8
9
|
include IdleMailer::Mailer
|
|
9
10
|
include IdleMailer::TemplateManager
|
|
10
11
|
|
|
12
|
+
# Initializes a new RegistrationMailer instance.
|
|
13
|
+
#
|
|
11
14
|
# @param user [ROM::Struct::User] The user object
|
|
12
15
|
def initialize(user)
|
|
13
16
|
@user = user
|
|
@@ -15,6 +18,9 @@ module AuctionFunCore
|
|
|
15
18
|
mail.subject = I18n.t("mail.user_context.registration.subject")
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
# Returns the template name for the RegistrationMailer.
|
|
22
|
+
#
|
|
23
|
+
# @return [String] The template name.
|
|
18
24
|
def self.template_name
|
|
19
25
|
IdleMailer.config.templates.join("user_context/registration")
|
|
20
26
|
end
|
|
@@ -10,10 +10,20 @@ module AuctionFunCore
|
|
|
10
10
|
MAX_RETRIES = 15
|
|
11
11
|
include Sidekiq::Job
|
|
12
12
|
|
|
13
|
+
# Captures an exception and logs it along with additional attributes.
|
|
14
|
+
#
|
|
15
|
+
# @param exception [Exception] The exception to be captured.
|
|
16
|
+
# @param attributes [Hash] Additional attributes to be logged.
|
|
17
|
+
# @return [void]
|
|
13
18
|
def capture_exception(exception, attributes = {})
|
|
14
19
|
Application[:logger].error("#{exception.message}. Parameters: #{attributes}")
|
|
15
20
|
end
|
|
16
21
|
|
|
22
|
+
# Calculates an exponential backoff interval for retrying the job.
|
|
23
|
+
#
|
|
24
|
+
# @param retry_count [Integer] The current retry count.
|
|
25
|
+
# @param measure [String] The unit of time to measure the interval.
|
|
26
|
+
# @return [Integer] The backoff interval in the specified measure.
|
|
17
27
|
def backoff_exponential_job(retry_count, measure = "seconds")
|
|
18
28
|
max_retries = Float(2**retry_count)
|
|
19
29
|
|
|
@@ -6,13 +6,18 @@ module AuctionFunCore
|
|
|
6
6
|
module AuctionContext
|
|
7
7
|
module PostAuction
|
|
8
8
|
##
|
|
9
|
-
#
|
|
9
|
+
# Background job class responsible for performing participant operations after an finished auction.
|
|
10
10
|
class ParticipantOperationJob < Workers::ApplicationJob
|
|
11
11
|
include Import["repos.user_context.user_repository"]
|
|
12
12
|
include Import["repos.auction_context.auction_repository"]
|
|
13
13
|
include Import["operations.auction_context.post_auction.participant_operation"]
|
|
14
14
|
|
|
15
|
-
#
|
|
15
|
+
# Executes the participant operation for the specified auction and participant.
|
|
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]
|
|
16
21
|
def perform(auction_id, participant_id, retry_count = 0)
|
|
17
22
|
auction = auction_repository.by_id!(auction_id)
|
|
18
23
|
participant = user_repository.by_id!(participant_id)
|