auction_fun_core 0.8.5 → 0.8.7
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/CHANGELOG.md +25 -0
- 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 +9 -0
- data/i18n/en-US/mail/application.en-US.yml +59 -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/pt-BR/contracts/contracts.pt-BR.yml +9 -0
- data/i18n/pt-BR/mail/application.pt-BR.yml +59 -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/user_context/registration.pt-BR.yml +0 -4
- data/lib/auction_fun_core/contracts/auction_context/post_auction/participant_contract.rb +42 -0
- data/lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb +41 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/closed_contract.rb +47 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb +48 -0
- data/lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb +48 -0
- data/lib/auction_fun_core/entities/auction.rb +6 -0
- data/lib/auction_fun_core/operations/auction_context/create_operation.rb +12 -2
- data/lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb +52 -0
- data/lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb +51 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/closed_operation.rb +100 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb +100 -0
- data/lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb +102 -0
- data/lib/auction_fun_core/operations/auction_context/processor/start_operation.rb +23 -11
- 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 +167 -26
- data/lib/auction_fun_core/relations/staffs.rb +1 -1
- data/lib/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer.rb +31 -0
- data/lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb +31 -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/user_context/registration.html.erb +2 -2
- data/lib/auction_fun_core/version.rb +1 -1
- data/lib/auction_fun_core/workers/application_job.rb +2 -0
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb +33 -0
- data/lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb +33 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job.rb +34 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb +37 -0
- data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb +34 -0
- data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job.rb +51 -0
- data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb +51 -0
- data/system/providers/background_job.rb +19 -0
- metadata +43 -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/services/mail/templates/auction_context/post_auction/winner.html.erb
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
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("mail.general.hello", name: @winner.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.post_auction.winner_mailer.body.description", title: @auction.title) %>
|
|
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><%= raw I18n.t("mail.auction_context.post_auction.winner_mailer.body.item.title", title: @auction.title) %></li>
|
|
77
|
+
<li><%= I18n.t("mail.auction_context.post_auction.winner_mailer.body.item.winner_bid", winner_bid: @statistics.winner_bid) %></li>
|
|
78
|
+
<li><%= I18n.t("mail.auction_context.post_auction.winner_mailer.body.item.auction_total_bids", auction_total_bids: @statistics.auction_total_bids) %></li>
|
|
79
|
+
<li><%= I18n.t("mail.auction_context.post_auction.winner_mailer.body.item.auction_date") %>: <%= I18n.l(@statistics.auction_date, format: :default) %></li>
|
|
80
|
+
</ul>
|
|
81
|
+
</td>
|
|
82
|
+
</tr>
|
|
83
|
+
<tr>
|
|
84
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
85
|
+
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:bold;line-height:24px;text-align:left;color:#434245;">
|
|
86
|
+
<%= I18n.t("application.general.team") %>
|
|
87
|
+
</div>
|
|
88
|
+
</td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
92
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation">
|
|
93
|
+
<tr>
|
|
94
|
+
<td>
|
|
95
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
96
|
+
<tbody>
|
|
97
|
+
<tr>
|
|
98
|
+
<td style="padding:4px;">
|
|
99
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
100
|
+
<tbody>
|
|
101
|
+
<tr>
|
|
102
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
103
|
+
<a href="https://twitter.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
104
|
+
<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" />
|
|
105
|
+
</a>
|
|
106
|
+
</td>
|
|
107
|
+
</tr>
|
|
108
|
+
</tbody>
|
|
109
|
+
</table>
|
|
110
|
+
</td>
|
|
111
|
+
</tr>
|
|
112
|
+
</tbody>
|
|
113
|
+
</table>
|
|
114
|
+
</td>
|
|
115
|
+
<td>
|
|
116
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
117
|
+
<tbody>
|
|
118
|
+
<tr>
|
|
119
|
+
<td style="padding:4px;">
|
|
120
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
121
|
+
<tbody>
|
|
122
|
+
<tr>
|
|
123
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
124
|
+
<a href="https://facebook.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
125
|
+
<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" />
|
|
126
|
+
</a>
|
|
127
|
+
</td>
|
|
128
|
+
</tr>
|
|
129
|
+
</tbody>
|
|
130
|
+
</table>
|
|
131
|
+
</td>
|
|
132
|
+
</tr>
|
|
133
|
+
</tbody>
|
|
134
|
+
</table>
|
|
135
|
+
</td>
|
|
136
|
+
<td>
|
|
137
|
+
<table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;">
|
|
138
|
+
<tbody>
|
|
139
|
+
<tr>
|
|
140
|
+
<td style="padding:4px;">
|
|
141
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:18px;">
|
|
142
|
+
<tbody>
|
|
143
|
+
<tr>
|
|
144
|
+
<td style="font-size:0;height:18px;vertical-align:middle;width:18px;">
|
|
145
|
+
<a href="https://instagram.com/auctionfun" target="_blank" style="color: #2e58ff; text-decoration: none;">
|
|
146
|
+
<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" />
|
|
147
|
+
</a>
|
|
148
|
+
</td>
|
|
149
|
+
</tr>
|
|
150
|
+
</tbody>
|
|
151
|
+
</table>
|
|
152
|
+
</td>
|
|
153
|
+
</tr>
|
|
154
|
+
</tbody>
|
|
155
|
+
</table>
|
|
156
|
+
</td>
|
|
157
|
+
</tr>
|
|
158
|
+
</table>
|
|
159
|
+
</td>
|
|
160
|
+
</tr>
|
|
161
|
+
</tbody>
|
|
162
|
+
</table>
|
|
163
|
+
</div>
|
|
164
|
+
</td>
|
|
165
|
+
</tr>
|
|
166
|
+
</table>
|
|
167
|
+
</td>
|
|
168
|
+
</tr>
|
|
169
|
+
</tbody>
|
|
170
|
+
</table>
|
|
171
|
+
</div>
|
|
172
|
+
</td>
|
|
173
|
+
</tr>
|
|
174
|
+
</table>
|
|
@@ -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: @user.name) %>,
|
|
33
33
|
</h1>
|
|
34
34
|
</div>
|
|
35
35
|
</td>
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
<tr>
|
|
80
80
|
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
81
81
|
<div style="font-family:Helvetica, Arial, sans-serif;font-size:18px;font-weight:bold;line-height:24px;text-align:left;color:#434245;">
|
|
82
|
-
<%= I18n.t("
|
|
82
|
+
<%= I18n.t("application.general.team") %>
|
|
83
83
|
</div>
|
|
84
84
|
</td>
|
|
85
85
|
</tr>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AuctionFunCore
|
|
4
|
+
module Workers
|
|
5
|
+
module Operations
|
|
6
|
+
module AuctionContext
|
|
7
|
+
module PostAuction
|
|
8
|
+
##
|
|
9
|
+
# BackgroundJob class for call finish auction operation.
|
|
10
|
+
class ParticipantOperationJob < Workers::ApplicationJob
|
|
11
|
+
include Import["repos.user_context.user_repository"]
|
|
12
|
+
include Import["repos.auction_context.auction_repository"]
|
|
13
|
+
include Import["operations.auction_context.post_auction.participant_operation"]
|
|
14
|
+
|
|
15
|
+
# @todo Add detailed documentation
|
|
16
|
+
def perform(auction_id, participant_id, retry_count = 0)
|
|
17
|
+
auction = auction_repository.by_id!(auction_id)
|
|
18
|
+
participant = user_repository.by_id!(participant_id)
|
|
19
|
+
|
|
20
|
+
participant_operation.call(auction_id: auction.id, participant_id: participant.id)
|
|
21
|
+
rescue => e
|
|
22
|
+
capture_exception(e, {auction_id: auction_id, participant_id: participant_id, retry_count: retry_count})
|
|
23
|
+
raise if retry_count >= MAX_RETRIES
|
|
24
|
+
|
|
25
|
+
interval = backoff_exponential_job(retry_count)
|
|
26
|
+
self.class.perform_at(interval, auction_id, participant_id, retry_count + 1)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AuctionFunCore
|
|
4
|
+
module Workers
|
|
5
|
+
module Operations
|
|
6
|
+
module AuctionContext
|
|
7
|
+
module PostAuction
|
|
8
|
+
##
|
|
9
|
+
# BackgroundJob class for call finish auction operation.
|
|
10
|
+
class WinnerOperationJob < Workers::ApplicationJob
|
|
11
|
+
include Import["repos.user_context.user_repository"]
|
|
12
|
+
include Import["repos.auction_context.auction_repository"]
|
|
13
|
+
include Import["operations.auction_context.post_auction.winner_operation"]
|
|
14
|
+
|
|
15
|
+
# @todo Add detailed documentation
|
|
16
|
+
def perform(auction_id, winner_id, retry_count = 0)
|
|
17
|
+
auction = auction_repository.by_id!(auction_id)
|
|
18
|
+
winner = user_repository.by_id!(winner_id)
|
|
19
|
+
|
|
20
|
+
winner_operation.call(auction_id: auction.id, winner_id: winner.id)
|
|
21
|
+
rescue => e
|
|
22
|
+
capture_exception(e, {auction_id: auction_id, winner_id: winner_id, retry_count: retry_count})
|
|
23
|
+
raise if retry_count >= MAX_RETRIES
|
|
24
|
+
|
|
25
|
+
interval = backoff_exponential_job(retry_count)
|
|
26
|
+
self.class.perform_at(interval, auction_id, winner_id, retry_count + 1)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
# BackgroundJob class for call finish closed auction operation.
|
|
11
|
+
#
|
|
12
|
+
class ClosedOperationJob < Workers::ApplicationJob
|
|
13
|
+
include Import["repos.auction_context.auction_repository"]
|
|
14
|
+
include Import["operations.auction_context.processor.finish.closed_operation"]
|
|
15
|
+
|
|
16
|
+
# @todo Add detailed documentation
|
|
17
|
+
def perform(auction_id, retry_count = 0)
|
|
18
|
+
auction = auction_repository.by_id!(auction_id)
|
|
19
|
+
|
|
20
|
+
closed_operation.call(auction_id: auction.id)
|
|
21
|
+
rescue => e
|
|
22
|
+
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
|
23
|
+
raise if retry_count >= MAX_RETRIES
|
|
24
|
+
|
|
25
|
+
interval = backoff_exponential_job(retry_count)
|
|
26
|
+
self.class.perform_at(interval, auction_id, retry_count + 1)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
# BackgroundJob class for call finish penny auction operation.
|
|
11
|
+
#
|
|
12
|
+
class PennyOperationJob < Workers::ApplicationJob
|
|
13
|
+
include Sidekiq::Worker
|
|
14
|
+
include Import["repos.auction_context.auction_repository"]
|
|
15
|
+
include Import["operations.auction_context.processor.finish.penny_operation"]
|
|
16
|
+
|
|
17
|
+
sidekiq_options queue: "default", lock: :until_executed, on_conflict: :replace
|
|
18
|
+
|
|
19
|
+
# @todo Add detailed documentation
|
|
20
|
+
def perform(auction_id, retry_count = 0)
|
|
21
|
+
auction = auction_repository.by_id!(auction_id)
|
|
22
|
+
|
|
23
|
+
penny_operation.call(auction_id: auction.id)
|
|
24
|
+
rescue => e
|
|
25
|
+
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
|
26
|
+
raise if retry_count >= MAX_RETRIES
|
|
27
|
+
|
|
28
|
+
interval = backoff_exponential_job(retry_count)
|
|
29
|
+
self.class.perform_at(interval, auction_id, retry_count + 1)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
# BackgroundJob class 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
|
+
# @todo Add detailed documentation
|
|
17
|
+
def perform(auction_id, retry_count = 0)
|
|
18
|
+
auction = auction_repository.by_id!(auction_id)
|
|
19
|
+
|
|
20
|
+
standard_operation.call(auction_id: auction.id)
|
|
21
|
+
rescue => e
|
|
22
|
+
capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
|
|
23
|
+
raise if retry_count >= MAX_RETRIES
|
|
24
|
+
|
|
25
|
+
interval = backoff_exponential_job(retry_count)
|
|
26
|
+
self.class.perform_at(interval, auction_id, retry_count + 1)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
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 ParticipantMailerJob < AuctionFunCore::Workers::ApplicationJob
|
|
13
|
+
include Import["repos.user_context.user_repository"]
|
|
14
|
+
include Import["repos.auction_context.auction_repository"]
|
|
15
|
+
|
|
16
|
+
# @param auction_id [Integer] auction ID
|
|
17
|
+
# @param participant_id [Integer] user ID
|
|
18
|
+
def perform(auction_id, participant_id, retry_count = 0)
|
|
19
|
+
auction = auction_repository.by_id!(auction_id)
|
|
20
|
+
participant = user_repository.by_id!(participant_id)
|
|
21
|
+
|
|
22
|
+
statistics = relation.load_participant_statistics.call(auction.id, participant.id).first
|
|
23
|
+
|
|
24
|
+
participant_mailer.new(auction, participant, statistics).deliver
|
|
25
|
+
rescue => e
|
|
26
|
+
capture_exception(e, {auction_id: auction_id, participant_id: participant_id, retry_count: retry_count})
|
|
27
|
+
raise e if retry_count >= MAX_RETRIES
|
|
28
|
+
|
|
29
|
+
interval = backoff_exponential_job(retry_count)
|
|
30
|
+
self.class.perform_at(interval, auction_id, participant_id, retry_count + 1)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# Since the shipping code structure does not follow project conventions,
|
|
36
|
+
# making the default injection dependency would be more complicated.
|
|
37
|
+
# Therefore, here I directly explain the class to be called.
|
|
38
|
+
def participant_mailer
|
|
39
|
+
AuctionFunCore::Services::Mail::AuctionContext::PostAuction::ParticipantMailer
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def relation
|
|
43
|
+
AuctionFunCore::Application[:container].relations[:auctions]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
# @param auction_id [Integer] auction ID
|
|
17
|
+
# @param winner_id [Integer] user ID
|
|
18
|
+
def perform(auction_id, winner_id, retry_count = 0)
|
|
19
|
+
auction = auction_repository.by_id!(auction_id)
|
|
20
|
+
winner = user_repository.by_id!(winner_id)
|
|
21
|
+
|
|
22
|
+
statistics = relation.load_winner_statistics.call(auction_id, winner_id).first
|
|
23
|
+
|
|
24
|
+
winner_mailer.new(auction, winner, statistics).deliver
|
|
25
|
+
rescue => e
|
|
26
|
+
capture_exception(e, {auction_id: auction_id, winner_id: winner_id, retry_count: retry_count})
|
|
27
|
+
raise e if retry_count >= MAX_RETRIES
|
|
28
|
+
|
|
29
|
+
interval = backoff_exponential_job(retry_count)
|
|
30
|
+
self.class.perform_at(interval, auction_id, winner_id, retry_count + 1)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# Since the shipping code structure does not follow project conventions,
|
|
36
|
+
# making the default injection dependency would be more complicated.
|
|
37
|
+
# Therefore, here I directly explain the class to be called.
|
|
38
|
+
def winner_mailer
|
|
39
|
+
AuctionFunCore::Services::Mail::AuctionContext::PostAuction::WinnerMailer
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def relation
|
|
43
|
+
AuctionFunCore::Application[:container].relations[:auctions]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -3,13 +3,32 @@
|
|
|
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
|
+
config.redis = {url: target[:settings].redis_url}
|
|
10
12
|
config.logger = target[:settings].logger
|
|
11
13
|
config.average_scheduled_poll_interval = 3
|
|
14
|
+
|
|
15
|
+
config.client_middleware do |chain|
|
|
16
|
+
chain.add SidekiqUniqueJobs::Middleware::Client
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
config.server_middleware do |chain|
|
|
20
|
+
chain.add SidekiqUniqueJobs::Middleware::Server
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
SidekiqUniqueJobs::Server.configure(config)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Sidekiq.configure_client do |config|
|
|
12
27
|
config.redis = {url: target[:settings].redis_url}
|
|
28
|
+
|
|
29
|
+
config.client_middleware do |chain|
|
|
30
|
+
chain.add SidekiqUniqueJobs::Middleware::Client
|
|
31
|
+
end
|
|
13
32
|
end
|
|
14
33
|
end
|
|
15
34
|
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.7
|
|
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-22 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,14 @@ 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
|
|
298
315
|
- i18n/en-US/mail/user_context/registration.en-US.yml
|
|
299
316
|
- i18n/pt-BR/contracts/contracts.pt-BR.yml
|
|
317
|
+
- i18n/pt-BR/mail/application.pt-BR.yml
|
|
318
|
+
- i18n/pt-BR/mail/auction_context/post_auction/participant.pt-BR.yml
|
|
319
|
+
- i18n/pt-BR/mail/auction_context/post_auction/winner.pt-BR.yml
|
|
300
320
|
- i18n/pt-BR/mail/user_context/registration.pt-BR.yml
|
|
301
321
|
- lib/auction_fun_core.rb
|
|
302
322
|
- lib/auction_fun_core/business/configuration.rb
|
|
@@ -311,7 +331,11 @@ files:
|
|
|
311
331
|
- lib/auction_fun_core/commands/user_context/create_user.rb
|
|
312
332
|
- lib/auction_fun_core/contracts/application_contract.rb
|
|
313
333
|
- lib/auction_fun_core/contracts/auction_context/create_contract.rb
|
|
314
|
-
- lib/auction_fun_core/contracts/auction_context/
|
|
334
|
+
- lib/auction_fun_core/contracts/auction_context/post_auction/participant_contract.rb
|
|
335
|
+
- lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb
|
|
336
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/closed_contract.rb
|
|
337
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb
|
|
338
|
+
- lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb
|
|
315
339
|
- lib/auction_fun_core/contracts/auction_context/processor/pause_contract.rb
|
|
316
340
|
- lib/auction_fun_core/contracts/auction_context/processor/start_contract.rb
|
|
317
341
|
- lib/auction_fun_core/contracts/auction_context/processor/unpause_contract.rb
|
|
@@ -331,7 +355,11 @@ files:
|
|
|
331
355
|
- lib/auction_fun_core/events/app.rb
|
|
332
356
|
- lib/auction_fun_core/events/listener.rb
|
|
333
357
|
- lib/auction_fun_core/operations/auction_context/create_operation.rb
|
|
334
|
-
- lib/auction_fun_core/operations/auction_context/
|
|
358
|
+
- lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb
|
|
359
|
+
- lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb
|
|
360
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/closed_operation.rb
|
|
361
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb
|
|
362
|
+
- lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb
|
|
335
363
|
- lib/auction_fun_core/operations/auction_context/processor/pause_operation.rb
|
|
336
364
|
- lib/auction_fun_core/operations/auction_context/processor/start_operation.rb
|
|
337
365
|
- lib/auction_fun_core/operations/auction_context/processor/unpause_operation.rb
|
|
@@ -353,13 +381,23 @@ files:
|
|
|
353
381
|
- lib/auction_fun_core/repos/bid_context/bid_repository.rb
|
|
354
382
|
- lib/auction_fun_core/repos/staff_context/staff_repository.rb
|
|
355
383
|
- lib/auction_fun_core/repos/user_context/user_repository.rb
|
|
384
|
+
- lib/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer.rb
|
|
385
|
+
- lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb
|
|
386
|
+
- lib/auction_fun_core/services/mail/templates/auction_context/post_auction/participant.html.erb
|
|
387
|
+
- lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb
|
|
356
388
|
- lib/auction_fun_core/services/mail/templates/layout.html.erb
|
|
357
389
|
- lib/auction_fun_core/services/mail/templates/user_context/registration.html.erb
|
|
358
390
|
- lib/auction_fun_core/services/mail/user_context/registration_mailer.rb
|
|
359
391
|
- lib/auction_fun_core/version.rb
|
|
360
392
|
- lib/auction_fun_core/workers/application_job.rb
|
|
361
|
-
- lib/auction_fun_core/workers/operations/auction_context/
|
|
393
|
+
- lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb
|
|
394
|
+
- lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb
|
|
395
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job.rb
|
|
396
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb
|
|
397
|
+
- lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb
|
|
362
398
|
- lib/auction_fun_core/workers/operations/auction_context/processor/start_operation_job.rb
|
|
399
|
+
- lib/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job.rb
|
|
400
|
+
- lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb
|
|
363
401
|
- lib/auction_fun_core/workers/services/mail/user_context/registration_mailer_job.rb
|
|
364
402
|
- lib/tasks/database.rake
|
|
365
403
|
- system/providers/background_job.rb
|