public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin4][RM3475] Execution time for a query or function shows only minutes part and not hour part
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin4][RM3475] Execution time for a query or function shows only minutes part and not hour part
@ 2019-01-15 13:47 Aditya Toshniwal <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Toshniwal @ 2019-01-15 13:47 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Attached is the patch to also display the hour part if the query execution
exceeds more than 1 hour, with some improvements is code. Test case added.
Kindly review.
--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Attachments:
[application/octet-stream] RM3475.patch (2.5K, 3-RM3475.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js b/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
index b163aac5..ba390511 100644
--- a/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
+++ b/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
@@ -10,24 +10,25 @@
import moment from 'moment';
export function calculateQueryRunTime(startTime, endTime) {
- const tempEndDate = moment(endTime);
- let miliseconds = tempEndDate.diff(startTime);
- let seconds = tempEndDate.diff(startTime, 'seconds');
- const minutes = tempEndDate.diff(startTime, 'minutes');
-
+ let total_ms = moment(endTime).diff(startTime);
let result = '';
- if (minutes > 0) {
- result += minutes + ' min ';
- seconds -= minutes * 60;
- }
+ let secs, mins, hrs;
+
+ /* Extract seconds from millisecs */
+ secs = parseInt(total_ms/1000);
+ total_ms = total_ms%1000;
+
+ /* Extract mins from seconds */
+ mins = parseInt(secs/60);
+ secs = secs%60;
- if (seconds > 0) {
- result += seconds + ' secs ';
- miliseconds -= seconds * 1000;
- }
+ /* Extract hrs from mins */
+ hrs = parseInt(mins/60);
+ mins = mins%60;
- if(minutes <= 0) {
- result += miliseconds + ' msec';
- }
+ 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();
}
diff --git a/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js b/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
index e5a58fe9..5d41813f 100644
--- a/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
+++ b/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
@@ -79,4 +79,27 @@ describe('#calculateQueryRunTime', () => {
.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');
+ });
+ });
});
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin4][RM3475] Execution time for a query or function shows only minutes part and not hour part
@ 2019-01-16 07:29 Akshay Joshi <[email protected]>
parent: Aditya Toshniwal <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Akshay Joshi @ 2019-01-16 07:29 UTC (permalink / raw)
To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers
Thanks patch applied.
On Tue, Jan 15, 2019 at 7:18 PM Aditya Toshniwal <
[email protected]> wrote:
> Hi Hackers,
>
> Attached is the patch to also display the hour part if the query execution
> exceeds more than 1 hour, with some improvements is code. Test case added.
>
> Kindly review.
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB Software Solutions | Pune
> "Don't Complain about Heat, Plant a tree"
>
--
*Akshay Joshi*
*Sr. Software Architect *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-01-16 07:29 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 13:47 [pgAdmin4][RM3475] Execution time for a query or function shows only minutes part and not hour part Aditya Toshniwal <[email protected]>
2019-01-16 07:29 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox