[PATCH] nmbug-status: add support for specifying sort order for each view
authorJani Nikula <jani@nikula.org>
Fri, 3 Apr 2015 07:57:12 +0000 (10:57 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:40 +0000 (14:48 -0700)
4d/113e288cc60921a218a48f758b350e896e9b27 [new file with mode: 0644]

diff --git a/4d/113e288cc60921a218a48f758b350e896e9b27 b/4d/113e288cc60921a218a48f758b350e896e9b27
new file mode 100644 (file)
index 0000000..675102a
--- /dev/null
@@ -0,0 +1,97 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 509316DE196A\r
+ for <notmuch@notmuchmail.org>; Fri,  3 Apr 2015 14:42:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.034\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.034 tagged_above=-999 required=5 tests=[AWL=1.054, \r
+ RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id q-a_HzcT_Gqw for <notmuch@notmuchmail.org>;\r
+ Fri,  3 Apr 2015 14:42:50 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 404426DE1966 for\r
+ <notmuch@notmuchmail.org>; Fri,  3 Apr 2015 14:42:50 -0700 (PDT)\r
+Received: by wgbdm7 with SMTP id dm7so119926778wgb.1\r
+ for <notmuch@notmuchmail.org>; Fri, 03 Apr 2015 14:42:48 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+ bh=RM2JTShIcCPsO/45Hg5V16J6jcfTcrBJmVny+5LM4Jk=;\r
+ b=kXZzIbIXxhNpzl4ZNZoYLJ7wk9gbMpqIrIX5Bvwxnm9XQGW6xt5nyugRlQMpLonQ5d\r
+ X4WjPqPY9JpEqqdSES+pm/NMySrY51LlJoIHJvmueo+Ov6S5ibwrBV5231dhnf6Pik6b\r
+ nzo2glRte2RzFUqQ3IPSK5IinHvY+kryf4kkLtnvuX7Vjuujtisr+loZCS051dvunss6\r
+ mXxzKLwOmrYihrtLj/FEzIJIEAWEgtMkFodYuElRwzZrEGQP1bw5JzATk1DZWlu83BkL\r
+ 53Thhgo5g//g4TvApdRzFezndsOvbv1lSYstljk+i2VdDFmzwfMQlDMOf3ljigXBH+CD\r
+ tYpg==\r
+X-Gm-Message-State:\r
+ ALoCoQkP5bEvOWEep7JTEfzbGONeescBSMbVDeVGLHWnV1vbQSgiVFYwGIxgqTjyARRBHNBtPw2U\r
+X-Received: by 10.194.19.197 with SMTP id h5mr2345296wje.109.1428047808953;\r
+ Fri, 03 Apr 2015 00:56:48 -0700 (PDT)\r
+Received: from localhost (mobile-internet-bceee3-101.dhcp.inet.fi.\r
+ [188.238.227.101])\r
+ by mx.google.com with ESMTPSA id nb9sm1658728wic.10.2015.04.03.00.56.47\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 03 Apr 2015 00:56:47 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] nmbug-status: add support for specifying sort order for each\r
+ view\r
+Date: Fri,  3 Apr 2015 10:57:12 +0300\r
+Message-Id: <1428047832-14922-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 03 Apr 2015 21:42:52 -0000\r
+\r
+Let each view have "sort" key with possible values "oldest-first",\r
+"newest-first", and "unsorted", and sort the results\r
+accordingly. Oldest first remains the default.\r
+---\r
+ devel/nmbug/nmbug-status | 10 +++++++++-\r
+ 1 file changed, 9 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status\r
+index 19dc48abf557..e1abf4db15ba 100755\r
+--- a/devel/nmbug/nmbug-status\r
++++ b/devel/nmbug/nmbug-status\r
+@@ -156,11 +156,19 @@ class Page (object):\r
+             stream.write(self.footer)\r
\r
+     def _write_view(self, database, view, stream):\r
++        sort = {\r
++            'oldest-first': notmuch.Query.SORT.OLDEST_FIRST,\r
++            'newest-first': notmuch.Query.SORT.NEWEST_FIRST,\r
++            'unsorted': notmuch.Query.SORT.UNSORTED\r
++        }\r
+         if 'query-string' not in view:\r
+             query = view['query']\r
+             view['query-string'] = ' and '.join(query)\r
+         q = notmuch.Query(database, view['query-string'])\r
+-        q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)\r
++        if 'sort' in view and view['sort'] in sort:\r
++            q.set_sort(sort[view['sort']])\r
++        else:\r
++            q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)\r
+         threads = self._get_threads(messages=q.search_messages())\r
+         self._write_view_header(view=view, stream=stream)\r
+         self._write_threads(threads=threads, stream=stream)\r
+-- \r
+2.1.4\r
+\r