unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] nmbug-status: add support for specifying sort order for each view
@ 2015-04-03  7:57 Jani Nikula
  2015-04-06 11:43 ` Tomi Ollila
  2015-04-06 15:56 ` W. Trevor King
  0 siblings, 2 replies; 8+ messages in thread
From: Jani Nikula @ 2015-04-03  7:57 UTC (permalink / raw)
  To: notmuch

Let each view have "sort" key with possible values "oldest-first",
"newest-first", and "unsorted", and sort the results
accordingly. Oldest first remains the default.
---
 devel/nmbug/nmbug-status | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 19dc48abf557..e1abf4db15ba 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -156,11 +156,19 @@ class Page (object):
             stream.write(self.footer)
 
     def _write_view(self, database, view, stream):
+        sort = {
+            'oldest-first': notmuch.Query.SORT.OLDEST_FIRST,
+            'newest-first': notmuch.Query.SORT.NEWEST_FIRST,
+            'unsorted': notmuch.Query.SORT.UNSORTED
+        }
         if 'query-string' not in view:
             query = view['query']
             view['query-string'] = ' and '.join(query)
         q = notmuch.Query(database, view['query-string'])
-        q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
+        if 'sort' in view and view['sort'] in sort:
+            q.set_sort(sort[view['sort']])
+        else:
+            q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
         threads = self._get_threads(messages=q.search_messages())
         self._write_view_header(view=view, stream=stream)
         self._write_threads(threads=threads, stream=stream)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-29 18:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03  7:57 [PATCH] nmbug-status: add support for specifying sort order for each view Jani Nikula
2015-04-06 11:43 ` Tomi Ollila
2015-04-06 15:56 ` W. Trevor King
2015-04-06 16:48   ` Tomi Ollila
2015-09-26 11:37     ` [PATCH v2] " Jani Nikula
2015-09-26 18:47       ` W. Trevor King
2015-09-29 11:27       ` David Bremner
2015-09-29 18:58         ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).