File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed
Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 22
33namespace YorCreative \QueryWatcher ;
44
5+ use Illuminate \Support \Facades \Config ;
56use Illuminate \Support \Facades \DB ;
67use YorCreative \QueryWatcher \Events \QueryEvent ;
78
@@ -12,19 +13,20 @@ class QueryWatcher
1213 */
1314 public static function listen (): void
1415 {
15- if (config ('querywatcher.enabled ' )) {
16- DB ::enableQueryLog ();
17-
16+ ! self ::isQueryWatcherEnabled () ?:
1817 DB ::listen (function ($ query ) {
1918 $ time_exceeds_ms_enabled = self ::timeExceedsMsEnabled ();
2019
21- if (isset ($ time_exceeds_ms_enabled )
22- && self ::getTimeExceedsMs () < $ query ->time
23- || ! isset ($ time_exceeds_ms_enabled )) {
20+ if ($ time_exceeds_ms_enabled && self ::getTimeExceedsMs () < $ query ->time
21+ || ! $ time_exceeds_ms_enabled ) {
2422 event (new QueryEvent ($ query ));
2523 }
2624 });
27- }
25+ }
26+
27+ public static function isQueryWatcherEnabled ()
28+ {
29+ return Config::get ('querywatcher.enabled ' ) ?? false ;
2830 }
2931
3032 /**
Original file line number Diff line number Diff line change @@ -17,18 +17,14 @@ class CaptureQueryTest extends TestCase
1717 */
1818 public function it_can_capture_a_query ()
1919 {
20- $ this ->markTestSkipped ('Uncomment for local development testing. Fails Github Pipeline Test. ' );
21-
2220 HTTP ::fake ();
2321
2422 (new Test ())
2523 ->newQuery ()
2624 ->get ();
2725
2826 $ this ->assertEventBroadcasted (
29- 'query.event ' ,
30- 'private-query.event. ' .config ('querywatcher.token ' ),
31- 1
27+ 'query.event '
3228 );
3329 }
3430
You can’t perform that action at this time.
0 commit comments