File tree Expand file tree Collapse file tree 6 files changed +25
-32
lines changed Expand file tree Collapse file tree 6 files changed +25
-32
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ parameters:
5050 - type : className
5151 regex : ^Bavix\\.*\\Internal\\Exceptions\\.*
5252
53+ - name : InternalListener
54+ collectors :
55+ - type : className
56+ regex : ^Bavix\\.*\\Internal\\Listeners\\.*
57+
5358 - name : Event
5459 collectors :
5560 - type : className
@@ -250,6 +255,9 @@ parameters:
250255 - UIException
251256 - Model
252257
258+ InternalListener :
259+ - ServiceInterface
260+
253261 ServiceInterface :
254262 - InternalException
255263 - EventInterface
Original file line number Diff line number Diff line change 99
1010final class TransactionBeginningListener
1111{
12- public function __construct (
13- private ConnectionServiceInterface $ connectionService ,
14- private RegulatorServiceInterface $ regulatorService
15- ) {
16- }
17-
1812 public function __invoke (): void
1913 {
20- if ($ this -> connectionService ->get ()->transactionLevel () === 1 ) {
21- $ this -> regulatorService ->purge ();
14+ if (app (ConnectionServiceInterface::class) ->get ()->transactionLevel () === 1 ) {
15+ app (RegulatorServiceInterface::class) ->purge ();
2216 }
2317 }
2418}
Original file line number Diff line number Diff line change 99
1010final class TransactionCommittedListener
1111{
12- public function __construct (
13- private ConnectionServiceInterface $ connectionService ,
14- private RegulatorServiceInterface $ regulatorService
15- ) {
16- }
17-
1812 public function __invoke (): void
1913 {
20- if ($ this -> connectionService ->get ()->transactionLevel () === 0 ) {
21- $ this -> regulatorService ->committed ();
14+ if (app (ConnectionServiceInterface::class) ->get ()->transactionLevel () === 0 ) {
15+ app (RegulatorServiceInterface::class) ->committed ();
2216 }
2317 }
2418}
Original file line number Diff line number Diff line change 99
1010final class TransactionCommittingListener
1111{
12- public function __construct (
13- private ConnectionServiceInterface $ connectionService ,
14- private RegulatorServiceInterface $ regulatorService
15- ) {
16- }
17-
1812 public function __invoke (): void
1913 {
2014 /**
2115 * In fact, this if is not needed here.
2216 * But in order to protect the code from changes in the framework, I added a check here.
2317 */
24- if ($ this -> connectionService ->get ()->transactionLevel () === 1 ) {
25- $ this -> regulatorService ->committing ();
18+ if (app (ConnectionServiceInterface::class) ->get ()->transactionLevel () === 1 ) {
19+ app (RegulatorServiceInterface::class) ->committing ();
2620 }
2721 }
2822}
Original file line number Diff line number Diff line change 99
1010final class TransactionRolledBackListener
1111{
12- public function __construct (
13- private ConnectionServiceInterface $ connectionService ,
14- private RegulatorServiceInterface $ regulatorService
15- ) {
16- }
17-
1812 public function __invoke (): void
1913 {
20- if ($ this -> connectionService ->get ()->transactionLevel () === 0 ) {
21- $ this -> regulatorService ->purge ();
14+ if (app (ConnectionServiceInterface::class) ->get ()->transactionLevel () === 0 ) {
15+ app (RegulatorServiceInterface::class) ->purge ();
2216 }
2317 }
2418}
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ public function create(array $attributes): Wallet
2929 */
3030 public function updateBalances (array $ data ): int
3131 {
32+ // One element gives x10 speedup, on some data
33+ if (count ($ data ) === 1 ) {
34+ return $ this ->wallet ->newQuery ()
35+ ->whereKey (key ($ data ))
36+ ->update ([
37+ 'balance ' => current ($ data ),
38+ ]);
39+ }
40+
3241 $ cases = [];
3342 foreach ($ data as $ walletId => $ balance ) {
3443 $ cases [] = 'WHEN id = ' . $ walletId . ' THEN ' . $ balance ;
You can’t perform that action at this time.
0 commit comments