From: Jani Nikula Date: Fri, 3 Apr 2015 07:57:12 +0000 (+0300) Subject: [PATCH] nmbug-status: add support for specifying sort order for each view X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e30f867ceb6578aef83bb5292a7b31905ee6d87e;p=notmuch-archives.git [PATCH] nmbug-status: add support for specifying sort order for each view --- diff --git a/4d/113e288cc60921a218a48f758b350e896e9b27 b/4d/113e288cc60921a218a48f758b350e896e9b27 new file mode 100644 index 000000000..675102abd --- /dev/null +++ b/4d/113e288cc60921a218a48f758b350e896e9b27 @@ -0,0 +1,97 @@ +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 509316DE196A + for ; Fri, 3 Apr 2015 14:42:52 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.034 +X-Spam-Level: * +X-Spam-Status: No, score=1.034 tagged_above=-999 required=5 tests=[AWL=1.054, + RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01] 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 q-a_HzcT_Gqw for ; + Fri, 3 Apr 2015 14:42:50 -0700 (PDT) +Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com + [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 404426DE1966 for + ; Fri, 3 Apr 2015 14:42:50 -0700 (PDT) +Received: by wgbdm7 with SMTP id dm7so119926778wgb.1 + for ; Fri, 03 Apr 2015 14:42:48 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id; + bh=RM2JTShIcCPsO/45Hg5V16J6jcfTcrBJmVny+5LM4Jk=; + b=kXZzIbIXxhNpzl4ZNZoYLJ7wk9gbMpqIrIX5Bvwxnm9XQGW6xt5nyugRlQMpLonQ5d + X4WjPqPY9JpEqqdSES+pm/NMySrY51LlJoIHJvmueo+Ov6S5ibwrBV5231dhnf6Pik6b + nzo2glRte2RzFUqQ3IPSK5IinHvY+kryf4kkLtnvuX7Vjuujtisr+loZCS051dvunss6 + mXxzKLwOmrYihrtLj/FEzIJIEAWEgtMkFodYuElRwzZrEGQP1bw5JzATk1DZWlu83BkL + 53Thhgo5g//g4TvApdRzFezndsOvbv1lSYstljk+i2VdDFmzwfMQlDMOf3ljigXBH+CD + tYpg== +X-Gm-Message-State: + ALoCoQkP5bEvOWEep7JTEfzbGONeescBSMbVDeVGLHWnV1vbQSgiVFYwGIxgqTjyARRBHNBtPw2U +X-Received: by 10.194.19.197 with SMTP id h5mr2345296wje.109.1428047808953; + Fri, 03 Apr 2015 00:56:48 -0700 (PDT) +Received: from localhost (mobile-internet-bceee3-101.dhcp.inet.fi. + [188.238.227.101]) + by mx.google.com with ESMTPSA id nb9sm1658728wic.10.2015.04.03.00.56.47 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 03 Apr 2015 00:56:47 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH] nmbug-status: add support for specifying sort order for each + view +Date: Fri, 3 Apr 2015 10:57:12 +0300 +Message-Id: <1428047832-14922-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +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: Fri, 03 Apr 2015 21:42:52 -0000 + +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 +