mirror of https://github.com/Fabio286/antares.git
feat(UI): query duration calc
This commit is contained in:
parent
4494e637f7
commit
777b73fa6f
|
@ -1206,10 +1206,13 @@ export class MySQLClient extends AntaresCore {
|
||||||
|
|
||||||
for (const query of queries) {
|
for (const query of queries) {
|
||||||
if (!query) continue;
|
if (!query) continue;
|
||||||
|
const timeStart = new Date();
|
||||||
|
let timeStop;
|
||||||
let keysArr = [];
|
let keysArr = [];
|
||||||
|
|
||||||
const { rows, report, fields, keys } = await new Promise((resolve, reject) => {
|
const { rows, report, fields, keys, duration } = await new Promise((resolve, reject) => {
|
||||||
this._connection.query({ sql: query, nestTables }, async (err, response, fields) => {
|
this._connection.query({ sql: query, nestTables }, async (err, response, fields) => {
|
||||||
|
timeStop = new Date();
|
||||||
const queryResult = response;
|
const queryResult = response;
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -1277,6 +1280,7 @@ export class MySQLClient extends AntaresCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
|
duration: timeStop - timeStart,
|
||||||
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false,
|
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false,
|
||||||
report: !Array.isArray(queryResult) ? queryResult : false,
|
report: !Array.isArray(queryResult) ? queryResult : false,
|
||||||
fields: remappedFields,
|
fields: remappedFields,
|
||||||
|
@ -1286,7 +1290,7 @@ export class MySQLClient extends AntaresCore {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
resultsArr.push({ rows, report, fields, keys });
|
resultsArr.push({ rows, report, fields, keys, duration });
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultsArr.length === 1 ? resultsArr[0] : resultsArr;
|
return resultsArr.length === 1 ? resultsArr[0] : resultsArr;
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-info">
|
<div class="workspace-query-info">
|
||||||
|
<div
|
||||||
|
v-if="results.length"
|
||||||
|
class="d-flex"
|
||||||
|
:title="$t('message.queryDuration')"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-timer-sand mdi-rotate-180 pr-1" /> <b>{{ durationsCount / 1000 }}s</b>
|
||||||
|
</div>
|
||||||
<div v-if="resultsCount">
|
<div v-if="resultsCount">
|
||||||
{{ $t('word.results') }}: <b>{{ resultsCount.toLocaleString() }}</b>
|
{{ $t('word.results') }}: <b>{{ resultsCount.toLocaleString() }}</b>
|
||||||
</div>
|
</div>
|
||||||
|
@ -84,6 +91,7 @@ export default {
|
||||||
isQuering: false,
|
isQuering: false,
|
||||||
results: [],
|
results: [],
|
||||||
resultsCount: 0,
|
resultsCount: 0,
|
||||||
|
durationsCount: 0,
|
||||||
affectedCount: 0,
|
affectedCount: 0,
|
||||||
editorHeight: 200
|
editorHeight: 200
|
||||||
};
|
};
|
||||||
|
@ -143,6 +151,7 @@ export default {
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
this.results = Array.isArray(response) ? response : [response];
|
this.results = Array.isArray(response) ? response : [response];
|
||||||
this.resultsCount += this.results.reduce((acc, curr) => acc + (curr.rows ? curr.rows.length : 0), 0);
|
this.resultsCount += this.results.reduce((acc, curr) => acc + (curr.rows ? curr.rows.length : 0), 0);
|
||||||
|
this.durationsCount += this.results.reduce((acc, curr) => acc + curr.duration, 0);
|
||||||
this.affectedCount += this.results.reduce((acc, curr) => acc + (curr.report ? curr.report.affectedRows : 0), 0);
|
this.affectedCount += this.results.reduce((acc, curr) => acc + (curr.report ? curr.report.affectedRows : 0), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -161,6 +170,7 @@ export default {
|
||||||
clearTabData () {
|
clearTabData () {
|
||||||
this.results = [];
|
this.results = [];
|
||||||
this.resultsCount = 0;
|
this.resultsCount = 0;
|
||||||
|
this.durationsCount = 0;
|
||||||
this.affectedCount = 0;
|
this.affectedCount = 0;
|
||||||
},
|
},
|
||||||
resize (e) {
|
resize (e) {
|
||||||
|
|
|
@ -64,6 +64,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-info">
|
<div class="workspace-query-info">
|
||||||
|
<div
|
||||||
|
v-if="results.length"
|
||||||
|
class="d-flex"
|
||||||
|
:title="$t('message.queryDuration')"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-timer-sand mdi-rotate-180 pr-1" /> <b>{{ results[0].duration / 1000 }}s</b>
|
||||||
|
</div>
|
||||||
<div v-if="results.length && results[0].rows">
|
<div v-if="results.length && results[0].rows">
|
||||||
{{ $t('word.results') }}: <b>{{ results[0].rows.length.toLocaleString() }}</b>
|
{{ $t('word.results') }}: <b>{{ results[0].rows.length.toLocaleString() }}</b>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -190,7 +190,8 @@ module.exports = {
|
||||||
tableFiller: 'Table Filler',
|
tableFiller: 'Table Filler',
|
||||||
fakeDataLanguage: 'Fake data language',
|
fakeDataLanguage: 'Fake data language',
|
||||||
searchForElements: 'Search for elements',
|
searchForElements: 'Search for elements',
|
||||||
selectAll: 'Select all'
|
selectAll: 'Select all',
|
||||||
|
queryDuration: 'Query duration'
|
||||||
},
|
},
|
||||||
faker: {
|
faker: {
|
||||||
address: 'Address',
|
address: 'Address',
|
||||||
|
|
Loading…
Reference in New Issue