Re: [PATCH v2] nmbug-status: add support for specifying sort order for each view

2015-09-29 Thread Tomi Ollila
On Tue, Sep 29 2015, David Bremner  wrote:

> Jani Nikula  writes:
>
>> Let each view have a "sort" key, typically used with values
>> "oldest-first" or "newest-first" (although all values in Query.SORT
>> are accepted), and sort the results accordingly. Oldest first remains
>> the default.
>
> pushed.

when can we expect nmbug status page update ? :D

>
> d

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] nmbug-status: add support for specifying sort order for each view

2015-09-29 Thread David Bremner
Jani Nikula  writes:

> Let each view have a "sort" key, typically used with values
> "oldest-first" or "newest-first" (although all values in Query.SORT
> are accepted), and sort the results accordingly. Oldest first remains
> the default.

pushed.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] nmbug-status: add support for specifying sort order for each view

2015-09-26 Thread W. Trevor King
Looks good to me ;).

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] nmbug-status: add support for specifying sort order for each view

2015-09-26 Thread Jani Nikula
Let each view have a "sort" key, typically used with values
"oldest-first" or "newest-first" (although all values in Query.SORT
are accepted), and sort the results accordingly. Oldest first remains
the default.

The dynamic approach of mapping sort values is as suggested by
W. Trevor King .
---
 devel/nmbug/nmbug-status | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index e845c2a5c8f7..a289798e3cc1 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -156,11 +156,20 @@ class Page (object):
 stream.write(self.footer)
 
 def _write_view(self, database, view, stream):
+# sort order, default to oldest-first
+sort_key = view.get('sort', 'oldest-first')
+# dynamically accept all values in Query.SORT
+sort_attribute = sort_key.upper().replace('-', '_')
+try:
+sort = getattr(notmuch.Query.SORT, sort_attribute)
+except AttributeError:
+raise ConfigError('Invalid sort setting for {}: {!r}'.format(
+view['title'], sort_key))
 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)
+q.set_sort(sort)
 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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch