From af1eb52437f20bc59b1cc4556e10f4df9ab6a770 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 6 Apr 2015 14:43:54 +0300 Subject: [PATCH] Re: [PATCH] nmbug-status: add support for specifying sort order for each view --- bb/f6e964673797a9ca3d90b77cd1ac9665ff94d8 | 99 +++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 bb/f6e964673797a9ca3d90b77cd1ac9665ff94d8 diff --git a/bb/f6e964673797a9ca3d90b77cd1ac9665ff94d8 b/bb/f6e964673797a9ca3d90b77cd1ac9665ff94d8 new file mode 100644 index 000000000..b7f4cbe79 --- /dev/null +++ b/bb/f6e964673797a9ca3d90b77cd1ac9665ff94d8 @@ -0,0 +1,99 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id B2FB96DE19CD + for ; Mon, 6 Apr 2015 04:53:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.226 +X-Spam-Level: * +X-Spam-Status: No, score=1.226 tagged_above=-999 required=5 tests=[AWL=0.574, + SPF_NEUTRAL=0.652] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id akUPbNz8k2E5 for ; + Mon, 6 Apr 2015 04:53:52 -0700 (PDT) +X-Greylist: delayed 572 seconds by postgrey-1.35 at arlo; + Mon, 06 Apr 2015 04:53:52 PDT +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 27F3C6DE19C7 + for ; Mon, 6 Apr 2015 04:53:52 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 4639210019F; + Mon, 6 Apr 2015 14:43:55 +0300 (EEST) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH] nmbug-status: add support for specifying sort order for + each view +In-Reply-To: <1428047832-14922-1-git-send-email-jani@nikula.org> +References: <1428047832-14922-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.19+107~gab55bdb (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 06 Apr 2015 11:53:54 -0000 + +On Fri, Apr 03 2015, Jani Nikula wrote: + +> 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. +> --- + +lgtm. + +Tomi + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2