auction_fun_core 0.8.7 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +2 -0
  3. data/CHANGELOG.md +29 -0
  4. data/Procfile +1 -0
  5. data/README.md +34 -32
  6. data/Rakefile +1 -1
  7. data/auction_fun_core.gemspec +1 -1
  8. data/i18n/en-US/contracts/contracts.en-US.yml +3 -0
  9. data/i18n/en-US/mail/application.en-US.yml +7 -0
  10. data/i18n/en-US/mail/auction_context/pre_auction/auction_start_reminder.en-US.yml +11 -0
  11. data/i18n/pt-BR/contracts/contracts.pt-BR.yml +3 -0
  12. data/i18n/pt-BR/mail/application.pt-BR.yml +7 -0
  13. data/i18n/pt-BR/mail/auction_context/pre_auction/auction_start_reminder.pt-BR.yml +11 -0
  14. data/lib/auction_fun_core/business/configuration.rb +31 -0
  15. data/lib/auction_fun_core/business/token_generator.rb +19 -1
  16. data/lib/auction_fun_core/contracts/application_contract.rb +9 -1
  17. data/lib/auction_fun_core/contracts/auction_context/create_contract.rb +35 -20
  18. data/lib/auction_fun_core/contracts/auction_context/post_auction/participant_contract.rb +23 -1
  19. data/lib/auction_fun_core/contracts/auction_context/post_auction/winner_contract.rb +22 -1
  20. data/lib/auction_fun_core/contracts/auction_context/pre_auction/auction_start_reminder_contract.rb +48 -0
  21. data/lib/auction_fun_core/contracts/auction_context/processor/finish/closed_contract.rb +19 -7
  22. data/lib/auction_fun_core/contracts/auction_context/processor/finish/penny_contract.rb +19 -7
  23. data/lib/auction_fun_core/contracts/auction_context/processor/finish/standard_contract.rb +19 -7
  24. data/lib/auction_fun_core/contracts/auction_context/processor/pause_contract.rb +16 -4
  25. data/lib/auction_fun_core/contracts/auction_context/processor/start_contract.rb +17 -5
  26. data/lib/auction_fun_core/contracts/auction_context/processor/unpause_contract.rb +16 -4
  27. data/lib/auction_fun_core/contracts/bid_context/create_bid_closed_contract.rb +20 -11
  28. data/lib/auction_fun_core/contracts/bid_context/create_bid_penny_contract.rb +18 -9
  29. data/lib/auction_fun_core/contracts/bid_context/create_bid_standard_contract.rb +19 -10
  30. data/lib/auction_fun_core/contracts/staff_context/authentication_contract.rb +18 -4
  31. data/lib/auction_fun_core/contracts/staff_context/registration_contract.rb +20 -8
  32. data/lib/auction_fun_core/contracts/user_context/authentication_contract.rb +18 -4
  33. data/lib/auction_fun_core/contracts/user_context/email_confirmation_contract.rb +17 -2
  34. data/lib/auction_fun_core/contracts/user_context/phone_confirmation_contract.rb +17 -2
  35. data/lib/auction_fun_core/contracts/user_context/registration_contract.rb +26 -8
  36. data/lib/auction_fun_core/entities/auction.rb +48 -4
  37. data/lib/auction_fun_core/entities/bid.rb +3 -2
  38. data/lib/auction_fun_core/entities/staff.rb +15 -2
  39. data/lib/auction_fun_core/entities/user.rb +31 -2
  40. data/lib/auction_fun_core/events/app.rb +8 -2
  41. data/lib/auction_fun_core/events/listener.rb +19 -16
  42. data/lib/auction_fun_core/operations/auction_context/create_operation.rb +25 -9
  43. data/lib/auction_fun_core/operations/auction_context/post_auction/participant_operation.rb +36 -3
  44. data/lib/auction_fun_core/operations/auction_context/post_auction/winner_operation.rb +36 -2
  45. data/lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb +96 -0
  46. data/lib/auction_fun_core/operations/auction_context/processor/finish/closed_operation.rb +82 -10
  47. data/lib/auction_fun_core/operations/auction_context/processor/finish/penny_operation.rb +81 -10
  48. data/lib/auction_fun_core/operations/auction_context/processor/finish/standard_operation.rb +81 -12
  49. data/lib/auction_fun_core/operations/auction_context/processor/pause_operation.rb +36 -1
  50. data/lib/auction_fun_core/operations/auction_context/processor/unpause_operation.rb +36 -1
  51. data/lib/auction_fun_core/relations/auctions.rb +178 -97
  52. data/lib/auction_fun_core/relations/bids.rb +18 -0
  53. data/lib/auction_fun_core/repos/auction_context/auction_repository.rb +40 -11
  54. data/lib/auction_fun_core/repos/bid_context/bid_repository.rb +27 -5
  55. data/lib/auction_fun_core/repos/staff_context/staff_repository.rb +63 -21
  56. data/lib/auction_fun_core/repos/user_context/user_repository.rb +69 -25
  57. data/lib/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer.rb +7 -1
  58. data/lib/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer.rb +7 -1
  59. data/lib/auction_fun_core/services/mail/auction_context/pre_auction/auction_start_reminder_mailer.rb +35 -0
  60. data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/participant.html.erb +1 -1
  61. data/lib/auction_fun_core/services/mail/templates/auction_context/post_auction/winner.html.erb +1 -1
  62. data/lib/auction_fun_core/services/mail/templates/auction_context/pre_auction/auction_start_reminder.html.erb +192 -0
  63. data/lib/auction_fun_core/services/mail/user_context/registration_mailer.rb +6 -0
  64. data/lib/auction_fun_core/version.rb +1 -1
  65. data/lib/auction_fun_core/workers/application_job.rb +10 -0
  66. data/lib/auction_fun_core/workers/operations/auction_context/post_auction/participant_operation_job.rb +7 -2
  67. data/lib/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job.rb +6 -2
  68. data/lib/auction_fun_core/workers/operations/auction_context/pre_auction/auction_start_reminder_operation_job.rb +44 -0
  69. data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job.rb +6 -3
  70. data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job.rb +6 -3
  71. data/lib/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job.rb +6 -2
  72. data/lib/auction_fun_core/workers/operations/auction_context/processor/start_operation_job.rb +6 -3
  73. data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job.rb +12 -7
  74. data/lib/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job.rb +11 -5
  75. data/lib/auction_fun_core/workers/services/mail/auction_context/pre_auction/auction_start_reminder_mailer_job.rb +48 -0
  76. data/lib/auction_fun_core/workers/services/mail/user_context/registration_mailer_job.rb +8 -6
  77. data/spec/auction_fun_core/contracts/auction_context/create_contract_spec.rb +158 -0
  78. data/spec/auction_fun_core/contracts/auction_context/post_auction/participant_contract_spec.rb +77 -0
  79. data/spec/auction_fun_core/contracts/auction_context/post_auction/winner_contract_spec.rb +76 -0
  80. data/spec/auction_fun_core/contracts/auction_context/pre_auction/auction_start_reminder_contract_spec.rb +48 -0
  81. data/spec/auction_fun_core/contracts/auction_context/processor/finish/closed_contract_spec.rb +59 -0
  82. data/spec/auction_fun_core/contracts/auction_context/processor/finish/penny_contract_spec.rb +59 -0
  83. data/spec/auction_fun_core/contracts/auction_context/processor/finish/standard_contract_spec.rb +59 -0
  84. data/spec/auction_fun_core/contracts/auction_context/processor/pause_contract_spec.rb +39 -0
  85. data/spec/auction_fun_core/contracts/auction_context/processor/start_contract_spec.rb +59 -0
  86. data/spec/auction_fun_core/contracts/auction_context/processor/unpause_contract_spec.rb +39 -0
  87. data/spec/auction_fun_core/contracts/bid_context/create_bid_closed_contract_spec.rb +130 -0
  88. data/spec/auction_fun_core/contracts/bid_context/create_bid_penny_contract_spec.rb +118 -0
  89. data/spec/auction_fun_core/contracts/bid_context/create_bid_standard_contract_spec.rb +154 -0
  90. data/spec/auction_fun_core/contracts/staff_context/authentication_contract_spec.rb +89 -0
  91. data/spec/auction_fun_core/contracts/staff_context/registration_contract_spec.rb +24 -0
  92. data/spec/auction_fun_core/contracts/user_context/authentication_contract_spec.rb +89 -0
  93. data/spec/auction_fun_core/contracts/user_context/email_confirmation_contract_spec.rb +54 -0
  94. data/spec/auction_fun_core/contracts/user_context/phone_confirmation_contract_spec.rb +54 -0
  95. data/spec/auction_fun_core/contracts/user_context/registration_contract_spec.rb +27 -0
  96. data/spec/auction_fun_core/entities/auction_spec.rb +75 -0
  97. data/spec/auction_fun_core/entities/bid_spec.rb +7 -0
  98. data/spec/auction_fun_core/entities/staff_spec.rb +38 -0
  99. data/spec/auction_fun_core/entities/user_spec.rb +106 -0
  100. data/spec/auction_fun_core/operations/auction_context/create_operation_spec.rb +126 -0
  101. data/spec/auction_fun_core/operations/auction_context/post_auction/participant_operation_spec.rb +88 -0
  102. data/spec/auction_fun_core/operations/auction_context/post_auction/winner_operation_spec.rb +76 -0
  103. data/spec/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation_spec.rb +98 -0
  104. data/spec/auction_fun_core/operations/auction_context/processor/finish/closed_operation_spec.rb +107 -0
  105. data/spec/auction_fun_core/operations/auction_context/processor/finish/penny_operation_spec.rb +107 -0
  106. data/spec/auction_fun_core/operations/auction_context/processor/finish/standard_operation_spec.rb +106 -0
  107. data/spec/auction_fun_core/operations/auction_context/processor/pause_operation_spec.rb +83 -0
  108. data/spec/auction_fun_core/operations/auction_context/processor/start_operation_spec.rb +147 -0
  109. data/spec/auction_fun_core/operations/auction_context/processor/unpause_operation_spec.rb +80 -0
  110. data/spec/auction_fun_core/operations/bid_context/create_bid_closed_operation_spec.rb +95 -0
  111. data/spec/auction_fun_core/operations/bid_context/create_bid_penny_operation_spec.rb +133 -0
  112. data/spec/auction_fun_core/operations/bid_context/create_bid_standard_operation_spec.rb +95 -0
  113. data/spec/auction_fun_core/operations/staff_context/authentication_operation_spec.rb +74 -0
  114. data/spec/auction_fun_core/operations/staff_context/registration_operation_spec.rb +93 -0
  115. data/spec/auction_fun_core/operations/user_context/authentication_operation_spec.rb +74 -0
  116. data/spec/auction_fun_core/operations/user_context/email_confirmation_operation_spec.rb +76 -0
  117. data/spec/auction_fun_core/operations/user_context/phone_confirmation_operation_spec.rb +76 -0
  118. data/spec/auction_fun_core/operations/user_context/registration_operation_spec.rb +100 -0
  119. data/spec/auction_fun_core/relations/auctions_spec.rb +471 -0
  120. data/spec/auction_fun_core/repos/auction_context/auction_repository_spec.rb +64 -0
  121. data/spec/auction_fun_core/repos/bid_context/bid_repository_spec.rb +64 -0
  122. data/spec/auction_fun_core/repos/staff_context/staff_repository_spec.rb +118 -0
  123. data/spec/auction_fun_core/repos/user_context/user_repository_spec.rb +117 -0
  124. data/spec/auction_fun_core/services/mail/auction_context/post_auction/participant_mailer_spec.rb +48 -0
  125. data/spec/auction_fun_core/services/mail/auction_context/post_auction/winner_mailer_spec.rb +48 -0
  126. data/spec/auction_fun_core/services/mail/auction_context/pre_auction/auction_start_reminder_mailer_spec.rb +40 -0
  127. data/spec/auction_fun_core/services/mail/user_context/registration_mailer_spec.rb +33 -0
  128. data/spec/auction_fun_core/workers/operations/auction_context/post_auction/participation_operation_job_spec.rb +54 -0
  129. data/spec/auction_fun_core/workers/operations/auction_context/post_auction/winner_operation_job_spec.rb +48 -0
  130. data/spec/auction_fun_core/workers/operations/auction_context/pre_auction/auction_start_reminder_operation_job_spec.rb +53 -0
  131. data/spec/auction_fun_core/workers/operations/auction_context/processor/finish/closed_operation_job_spec.rb +47 -0
  132. data/spec/auction_fun_core/workers/operations/auction_context/processor/finish/penny_operation_job_spec.rb +47 -0
  133. data/spec/auction_fun_core/workers/operations/auction_context/processor/finish/standard_operation_job_spec.rb +47 -0
  134. data/spec/auction_fun_core/workers/operations/auction_context/processor/start_operation_job_spec.rb +47 -0
  135. data/spec/auction_fun_core/workers/services/mail/auction_context/post_auction/participant_mailer_job_spec.rb +62 -0
  136. data/spec/auction_fun_core/workers/services/mail/auction_context/post_auction/pre_auction/auction_start_reminder_mailer_job_spec.rb +59 -0
  137. data/spec/auction_fun_core/workers/services/mail/auction_context/post_auction/winner_mailer_job_spec.rb +62 -0
  138. data/spec/auction_fun_core/workers/services/mail/user_context/registration_mailer_job_spec.rb +53 -0
  139. data/spec/auction_fun_core_spec.rb +7 -0
  140. data/spec/spec_helper.rb +61 -0
  141. data/spec/support/background_job.rb +7 -0
  142. data/spec/support/factories/auctions.rb +143 -0
  143. data/spec/support/factories/bids.rb +6 -0
  144. data/spec/support/factories/staffs.rb +18 -0
  145. data/spec/support/factories/users.rb +43 -0
  146. data/spec/support/faker.rb +6 -0
  147. data/spec/support/mail.rb +13 -0
  148. data/spec/support/shared_examples/validate_email_contract.rb +25 -0
  149. data/spec/support/shared_examples/validate_name_contract.rb +19 -0
  150. data/spec/support/shared_examples/validate_password_confirmation_contract.rb +16 -0
  151. data/spec/support/shared_examples/validate_password_contract.rb +18 -0
  152. data/spec/support/shared_examples/validate_phone_contract.rb +25 -0
  153. data/spec/support/shared_examples/validate_stopwatch_contract.rb +32 -0
  154. data/system/providers/background_job.rb +6 -0
  155. metadata +87 -2
@@ -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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AuctionFunCore
4
- VERSION = "0.8.7"
4
+ VERSION = "0.8.10"
5
5
 
6
6
  # Required class module is a gem dependency
7
7
  class Version; 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
- # BackgroundJob class for call finish auction operation.
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
- # @todo Add detailed documentation
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)
@@ -6,13 +6,17 @@ module AuctionFunCore
6
6
  module AuctionContext
7
7
  module PostAuction
8
8
  ##
9
- # BackgroundJob class for call finish auction operation.
9
+ # Background job class responsible for performing winner operations after an finished auction.
10
10
  class WinnerOperationJob < 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.winner_operation"]
14
14
 
15
- # @todo Add detailed documentation
15
+ # Executes the winner operation for the specified auction and winner.
16
+ #
17
+ # @param auction_id [Integer] The ID of the auction.
18
+ # @param winner_id [Integer] The ID of the winner.
19
+ # @param retry_count [Integer] The current retry count for the job.
16
20
  def perform(auction_id, winner_id, retry_count = 0)
17
21
  auction = auction_repository.by_id!(auction_id)
18
22
  winner = user_repository.by_id!(winner_id)
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AuctionFunCore
4
+ module Workers
5
+ module Operations
6
+ module AuctionContext
7
+ module PreAuction
8
+ ##
9
+ # Background job class responsible for sending auction start reminders
10
+ class AuctionStartReminderOperationJob < Workers::ApplicationJob
11
+ include Import["repos.user_context.user_repository"]
12
+ include Import["repos.auction_context.auction_repository"]
13
+
14
+ # Executes the auction start reminder operation for the specified auction.
15
+ #
16
+ # @param auction_id [Integer] The ID of the auction.
17
+ # @param retry_count [Integer] The current retry count for the job.
18
+ # @return [void]
19
+ def perform(auction_id, retry_count = 0)
20
+ auction = auction_repository.by_id!(auction_id)
21
+
22
+ auction_start_reminder_operation.call(auction_id: auction.id)
23
+ rescue => e
24
+ capture_exception(e, {auction_id: auction_id, retry_count: retry_count})
25
+ raise if retry_count >= MAX_RETRIES
26
+
27
+ interval = backoff_exponential_job(retry_count)
28
+ self.class.perform_at(interval, auction_id, retry_count + 1)
29
+ end
30
+
31
+ private
32
+
33
+ # Retrieves the auction start reminder operation.
34
+ #
35
+ # @return [Class] The auction start reminder operation class.
36
+ def auction_start_reminder_operation
37
+ AuctionFunCore::Operations::AuctionContext::PreAuction::AuctionStartReminderOperation
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -7,13 +7,16 @@ module AuctionFunCore
7
7
  module Processor
8
8
  module Finish
9
9
  ##
10
- # BackgroundJob class for call finish closed auction operation.
11
- #
10
+ # Background job class responsible for call finish closed auction operation.
12
11
  class ClosedOperationJob < Workers::ApplicationJob
13
12
  include Import["repos.auction_context.auction_repository"]
14
13
  include Import["operations.auction_context.processor.finish.closed_operation"]
15
14
 
16
- # @todo Add detailed documentation
15
+ # Executes the operation to finish a closed auction.
16
+ #
17
+ # @param auction_id [Integer] The ID of the closed auction.
18
+ # @param retry_count [Integer] The current retry count for the job.
19
+ # @return [void]
17
20
  def perform(auction_id, retry_count = 0)
18
21
  auction = auction_repository.by_id!(auction_id)
19
22
 
@@ -7,8 +7,7 @@ module AuctionFunCore
7
7
  module Processor
8
8
  module Finish
9
9
  ##
10
- # BackgroundJob class for call finish penny auction operation.
11
- #
10
+ # Background job class responsible for call finish penny auction operation.
12
11
  class PennyOperationJob < Workers::ApplicationJob
13
12
  include Sidekiq::Worker
14
13
  include Import["repos.auction_context.auction_repository"]
@@ -16,7 +15,11 @@ module AuctionFunCore
16
15
 
17
16
  sidekiq_options queue: "default", lock: :until_executed, on_conflict: :replace
18
17
 
19
- # @todo Add detailed documentation
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]
20
23
  def perform(auction_id, retry_count = 0)
21
24
  auction = auction_repository.by_id!(auction_id)
22
25
 
@@ -7,13 +7,17 @@ module AuctionFunCore
7
7
  module Processor
8
8
  module Finish
9
9
  ##
10
- # BackgroundJob class for call finish standard auction operation.
10
+ # Background job class responsible for call finish standard auction operation.
11
11
  #
12
12
  class StandardOperationJob < Workers::ApplicationJob
13
13
  include Import["repos.auction_context.auction_repository"]
14
14
  include Import["operations.auction_context.processor.finish.standard_operation"]
15
15
 
16
- # @todo Add detailed documentation
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]
17
21
  def perform(auction_id, retry_count = 0)
18
22
  auction = auction_repository.by_id!(auction_id)
19
23
 
@@ -6,13 +6,16 @@ module AuctionFunCore
6
6
  module AuctionContext
7
7
  module Processor
8
8
  ##
9
- # BackgroundJob class for call start auction operation.
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
- # @todo Add detailed documentation
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
 
@@ -7,14 +7,17 @@ module AuctionFunCore
7
7
  module AuctionContext
8
8
  module PostAuction
9
9
  ##
10
- # Background job class responsible for adding emails to the queue.
11
- #
10
+ # Background job class responsible for queuing participant emails.
12
11
  class ParticipantMailerJob < AuctionFunCore::Workers::ApplicationJob
13
12
  include Import["repos.user_context.user_repository"]
14
13
  include Import["repos.auction_context.auction_repository"]
15
14
 
16
- # @param auction_id [Integer] auction ID
17
- # @param participant_id [Integer] user ID
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]
18
21
  def perform(auction_id, participant_id, retry_count = 0)
19
22
  auction = auction_repository.by_id!(auction_id)
20
23
  participant = user_repository.by_id!(participant_id)
@@ -32,13 +35,15 @@ module AuctionFunCore
32
35
 
33
36
  private
34
37
 
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
+ # Directly specifies the class to be called due to non-standard dependency injection.
39
+ # @return [Class] The participant mailer class.
38
40
  def participant_mailer
39
41
  AuctionFunCore::Services::Mail::AuctionContext::PostAuction::ParticipantMailer
40
42
  end
41
43
 
44
+ # Retrieves the relation for loading participant statistics.
45
+ #
46
+ # @return [ROM::Relation] The relation object.
42
47
  def relation
43
48
  AuctionFunCore::Application[:container].relations[:auctions]
44
49
  end
@@ -13,8 +13,12 @@ module AuctionFunCore
13
13
  include Import["repos.user_context.user_repository"]
14
14
  include Import["repos.auction_context.auction_repository"]
15
15
 
16
- # @param auction_id [Integer] auction ID
17
- # @param winner_id [Integer] user ID
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]
18
22
  def perform(auction_id, winner_id, retry_count = 0)
19
23
  auction = auction_repository.by_id!(auction_id)
20
24
  winner = user_repository.by_id!(winner_id)
@@ -32,13 +36,15 @@ module AuctionFunCore
32
36
 
33
37
  private
34
38
 
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.
39
+ # Directly specifies the class to be called due to non-standard dependency injection.
40
+ # @return [Class] The winner mailer class.
38
41
  def winner_mailer
39
42
  AuctionFunCore::Services::Mail::AuctionContext::PostAuction::WinnerMailer
40
43
  end
41
44
 
45
+ # Retrieves the relation for loading winner statistics.
46
+ #
47
+ # @return [ROM::Relation] The relation object.
42
48
  def relation
43
49
  AuctionFunCore::Application[:container].relations[:auctions]
44
50
  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 adding emails to the queue.
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
- # @param user_id [Integer] user ID
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
- # Since the shipping code structure does not follow project conventions,
30
- # making the default injection dependency would be more complicated.
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