mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Fixed execution time to show Hours part for long running queries in Query Tool. Fixes #3475
This commit is contained in:
parent
d7b0508305
commit
dec43d98dc
@ -15,5 +15,6 @@ Bug fixes
|
|||||||
*********
|
*********
|
||||||
|
|
||||||
| `Bug #3453 <https://redmine.postgresql.org/issues/3453>`_ - Fixed SQL for foreign table options.
|
| `Bug #3453 <https://redmine.postgresql.org/issues/3453>`_ - Fixed SQL for foreign table options.
|
||||||
|
| `Bug #3475 <https://redmine.postgresql.org/issues/3475>`_ - Fixed execution time to show Hours part for long running queries in Query Tool.
|
||||||
| `Bug #3693 <https://redmine.postgresql.org/issues/3693>`_ - Proper error should be thrown when server group is created with existing name.
|
| `Bug #3693 <https://redmine.postgresql.org/issues/3693>`_ - Proper error should be thrown when server group is created with existing name.
|
||||||
| `Bug #3695 <https://redmine.postgresql.org/issues/3695>`_ - Ensure long string should be wrap in alertify dialogs.
|
| `Bug #3695 <https://redmine.postgresql.org/issues/3695>`_ - Ensure long string should be wrap in alertify dialogs.
|
@ -10,24 +10,25 @@
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export function calculateQueryRunTime(startTime, endTime) {
|
export function calculateQueryRunTime(startTime, endTime) {
|
||||||
const tempEndDate = moment(endTime);
|
let total_ms = moment(endTime).diff(startTime);
|
||||||
let miliseconds = tempEndDate.diff(startTime);
|
|
||||||
let seconds = tempEndDate.diff(startTime, 'seconds');
|
|
||||||
const minutes = tempEndDate.diff(startTime, 'minutes');
|
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
if (minutes > 0) {
|
let secs, mins, hrs;
|
||||||
result += minutes + ' min ';
|
|
||||||
seconds -= minutes * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seconds > 0) {
|
/* Extract seconds from millisecs */
|
||||||
result += seconds + ' secs ';
|
secs = parseInt(total_ms/1000);
|
||||||
miliseconds -= seconds * 1000;
|
total_ms = total_ms%1000;
|
||||||
}
|
|
||||||
|
|
||||||
if(minutes <= 0) {
|
/* Extract mins from seconds */
|
||||||
result += miliseconds + ' msec';
|
mins = parseInt(secs/60);
|
||||||
}
|
secs = secs%60;
|
||||||
|
|
||||||
|
/* Extract hrs from mins */
|
||||||
|
hrs = parseInt(mins/60);
|
||||||
|
mins = mins%60;
|
||||||
|
|
||||||
|
result = (hrs>0 ? hrs + ' hr ': '')
|
||||||
|
+ (mins>0 ? mins + ' min ': '')
|
||||||
|
+ (hrs<=0 && secs>0 ? secs + ' secs ': '')
|
||||||
|
+ (hrs<=0 && mins<=0 ? total_ms + ' msec ':'');
|
||||||
return result.trim();
|
return result.trim();
|
||||||
}
|
}
|
||||||
|
@ -79,4 +79,27 @@ describe('#calculateQueryRunTime', () => {
|
|||||||
.toEqual('9 min 54 secs');
|
.toEqual('9 min 54 secs');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('time difference is bigger then 1 hour', () => {
|
||||||
|
it('displays seconds, milliseconds', () => {
|
||||||
|
let startDate = moment({
|
||||||
|
years:2018,
|
||||||
|
months:4,
|
||||||
|
date:2,
|
||||||
|
hours:10,
|
||||||
|
minutes:30,
|
||||||
|
seconds:20,
|
||||||
|
milliseconds:123}).toDate();
|
||||||
|
let endDate = moment({
|
||||||
|
years:2018,
|
||||||
|
months:4,
|
||||||
|
date:2,
|
||||||
|
hours:11,
|
||||||
|
minutes:40,
|
||||||
|
seconds:15,
|
||||||
|
milliseconds:70}).toDate();
|
||||||
|
expect(calculateQueryRunTime(startDate, endDate))
|
||||||
|
.toEqual('1 hr 9 min');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user