public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pradip Parkale <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM5842]: Query history shown out of order
Date: Fri, 23 Oct 2020 10:06:39 +0530
Message-ID: <CAJ9T6SsRk7XAi+cd1ay0OGjhRUgYiXXHDCvwG0jy4B1L=mmUuA@mail.gmail.com> (raw)

Hi Hackers,

Please find the attached patch to sort the query history in
descending order.

-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] RM5842.patch (1.2K, 3-RM5842.patch)
  download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor/history/query_history_entries.js b/web/pgadmin/static/js/sqleditor/history/query_history_entries.js
index 03ea7c46f..41d5cc310 100644
--- a/web/pgadmin/static/js/sqleditor/history/query_history_entries.js
+++ b/web/pgadmin/static/js/sqleditor/history/query_history_entries.js
@@ -235,8 +235,24 @@ export class QueryHistoryEntries {
     newItem.onClick(this.setSelectedListItem.bind(this));
     newItem.render(this.is_pgadmin_queries_shown);
 
-    if (!_.isUndefined($groupEl))
-      $groupEl.find('.query-entries').prepend(newItem.$el);
+    if (!_.isUndefined($groupEl)){
+      let entries = $groupEl.find('.query-entries').find('.list-item');
+      let i=0;
+      if(entries.length > 0)
+      {
+        while(i<entries.length){
+          if(newItem.$el.attr('data-key') > $(entries[i]).attr('data-key')) {
+            $(newItem.$el).insertBefore(entries[i]);
+            break;
+          }else{
+            $(newItem.$el).insertAfter(entries[i]);
+          }
+          i++;
+        }
+      } else{
+        $groupEl.find('.query-entries').append(newItem.$el);
+      }
+    }
     this.setSelectedListItem(newItem.$el);
   }
 


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin][RM5842]: Query history shown out of order
  In-Reply-To: <CAJ9T6SsRk7XAi+cd1ay0OGjhRUgYiXXHDCvwG0jy4B1L=mmUuA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox