Skip to content

Commit

Permalink
Merge pull request #26 from socialblue/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mbroersen committed Mar 4, 2020
2 parents f680782 + 216164f commit e326676
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/app.js": "/app.js?id=f6f83b8a5747597b9511",
"/app.js": "/app.js?id=76e4de08a7f359299cba",
"/app.css": "/app.css?id=a45caf0b385ad40f02c2"
}
14 changes: 12 additions & 2 deletions resources/assets/js/components/query-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
methods: {
showExplainDialog() {
window.EventBus.$emit('show-explain-dialog', [this.time, this.timeKey])
window.EventBus.$emit('show-explain-dialog', {
time: this.time,
timeKey: this.timeKey,
})
},
showExecuteDialog() {
Expand All @@ -35,6 +38,13 @@
timeKey: this.timeKey,
sql: this.sql
})
},
clipboardSuccess() {
this.showNotification = true;
setTimeout(() => {
this.showNotification = false;
}, 3000);
}
},
Expand Down Expand Up @@ -105,7 +115,7 @@
</nav>
</transition>

<a class="card-footer-item" title="copy sql" v-clipboard="format(sql)" v-clipboard:success="() => {showNotification = true}">
<a class="card-footer-item" title="copy sql" v-clipboard="format(sql)" v-clipboard:success="clipboardSuccess">
<span class="material-icons button is-small">
file_copy
</span>
Expand Down
25 changes: 9 additions & 16 deletions resources/assets/js/components/query-explain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
ExplainPart
},
props: {
time: {
type: Number
},
timeKey: {
type: Number
}
},
data() {
return {
explainParts: [],
Expand Down Expand Up @@ -62,12 +52,15 @@
mounted() {
window.EventBus.$on(`show-explain-dialog`, (data)=> {
if (data[0] === this.time && data[1] === this.timeKey) {
this.loadExplainParts();
this.$nextTick().then(() => {
this.active = true;
});
}
this.time = data.time;
this.timeKey = data.timeKey;
this.loadExplainParts();
this.$nextTick().then(() => {
this.active = true;
});
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/view/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</p>
</nav>
<query-execute></query-execute>
<query-explain></query-explain>

<nav class="panel" v-for="(queries, time) in cachedKeys">
<p class="panel-heading">
Expand All @@ -35,8 +36,6 @@
:execution-time="query.time"
>
</query-block>

<query-explain :time-key="key" :time="+time"></query-explain>
</div>
</div>
</nav>
Expand Down
14 changes: 10 additions & 4 deletions src/DataListener/QueryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,26 @@ public static function listen(QueryExecuted $query) {
static function ($trace) {
return isset($trace['file']) &&
strpos($trace['file'], 'vendor/laravel/framework/src') === false &&
isset($trace['object']) &&
property_exists($trace['object'], 'model');
isset($trace['object']);

}
);

array_walk($possibleTraces, static function (&$trace) {
if (method_exists($trace['object'], 'getModel')) {
$trace['model'] = $trace['object']->getModel();
$a = $trace['object']->getModel();
if (is_string($a)) {
$trace['model'] = $a;
} else {
$trace['model'] = get_class($a);
}
}
unset($trace['object']);
unset($trace['args']);
});

$data[time()][] = [
'backtrace' => debug_backtrace(0, 25),
'backtrace' => $possibleTraces,
'sql' => QueryBuilderHelper::combineQueryAndBindings($query->sql, $query->bindings),
'rawsql' => $query->sql,
'bindings' => $query->bindings,
Expand Down

0 comments on commit e326676

Please sign in to comment.