From: Wael M. Nasreddine Date: Sat, 10 May 2014 21:40:11 +0000 (+1700) Subject: [PATCH] ruby: Add wrapper for notmuch_query_count_threads X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1eae39caa7be9c166ea33081fa4be262c89e3c9d;p=notmuch-archives.git [PATCH] ruby: Add wrapper for notmuch_query_count_threads --- diff --git a/0c/b21065be0a272bf6013e4749ff1aea97bcfdd9 b/0c/b21065be0a272bf6013e4749ff1aea97bcfdd9 new file mode 100644 index 000000000..2e7194c49 --- /dev/null +++ b/0c/b21065be0a272bf6013e4749ff1aea97bcfdd9 @@ -0,0 +1,124 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1C010431FCF + for ; Sat, 10 May 2014 14:40:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.099 +X-Spam-Level: +X-Spam-Status: No, score=-0.099 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6uasiR7Id1Ok for ; + Sat, 10 May 2014 14:40:19 -0700 (PDT) +Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com + [209.85.192.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 37E0A431FC0 + for ; Sat, 10 May 2014 14:40:19 -0700 (PDT) +Received: by mail-pd0-f174.google.com with SMTP id w10so5011919pde.5 + for ; Sat, 10 May 2014 14:40:18 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=XgR3UYfdC5orUhYJGVI+HbeUu+9Am7ujymxme465g4M=; + b=jd8JGIXEP9uNgg7grerq0+HX07Ofi7aFj5aj1+p1JrQsEiBpNaamsBubZEyrmA23oV + VD5eADQuUavIgSeE60K+gPSUyowwzeIFK8u2wj4wOPsTGDztSks0KrdbRxzW8O1Jbyly + kGYeymh3ipmCm7LvQfAY556V61GNAf2gu+Mm9S3bRJOJAYkG3zjAuwcX/vgjD73DmcQU + my2HQp5Zqsau1yOQCB88PIYdytNhIMy/kwRF0gwV9xKaft/OWRmKHiWftrF3Vc+ay0h2 + zFgWmsywUY49ZlORfSf0qwN2FduMkqKmSykj22FMTWfimz9/Aqd5nRg6KnrxuhzINY3y + wkoA== +X-Received: by 10.66.148.70 with SMTP id tq6mr37060602pab.56.1399758018358; + Sat, 10 May 2014 14:40:18 -0700 (PDT) +Received: from localhost ([2620:0:1000:2e00:dc94:fbf5:1606:3c5b]) + by mx.google.com with ESMTPSA id + zv3sm26772175pab.20.2014.05.10.14.40.17 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 10 May 2014 14:40:17 -0700 (PDT) +From: "Wael M. Nasreddine" +To: notmuch@notmuchmail.org +Subject: [PATCH] ruby: Add wrapper for notmuch_query_count_threads +Date: Sat, 10 May 2014 14:40:11 -0700 +Message-Id: <1399758011-26217-2-git-send-email-wael.nasreddine@gmail.com> +X-Mailer: git-send-email 1.9.1.423.g4596e3a +In-Reply-To: <1399758011-26217-1-git-send-email-wael.nasreddine@gmail.com> +References: <1399758011-26217-1-git-send-email-wael.nasreddine@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Sat, 10 May 2014 21:40:24 -0000 + +--- + bindings/ruby/defs.h | 3 +++ + bindings/ruby/init.c | 1 + + bindings/ruby/query.c | 19 +++++++++++++++++++ + 3 files changed, 23 insertions(+) + +diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h +index 5b44585..f4901a0 100644 +--- a/bindings/ruby/defs.h ++++ b/bindings/ruby/defs.h +@@ -231,6 +231,9 @@ notmuch_rb_query_search_messages (VALUE self); + VALUE + notmuch_rb_query_count_messages (VALUE self); + ++VALUE ++notmuch_rb_query_count_threads (VALUE self); ++ + /* threads.c */ + VALUE + notmuch_rb_threads_destroy (VALUE self); +diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c +index 663271d..ab3f22d 100644 +--- a/bindings/ruby/init.c ++++ b/bindings/ruby/init.c +@@ -271,6 +271,7 @@ Init_notmuch (void) + rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */ + rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */ + rb_define_method (notmuch_rb_cQuery, "count_messages", notmuch_rb_query_count_messages, 0); /* in query.c */ ++ rb_define_method (notmuch_rb_cQuery, "count_threads", notmuch_rb_query_count_threads, 0); /* in query.c */ + + /* + * Document-class: Notmuch::Threads +diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c +index 1658ede..a7dacba 100644 +--- a/bindings/ruby/query.c ++++ b/bindings/ruby/query.c +@@ -182,3 +182,22 @@ notmuch_rb_query_count_messages (VALUE self) + */ + return UINT2NUM(notmuch_query_count_messages(query)); + } ++ ++/* ++ * call-seq: QUERY.count_threads => Fixnum ++ * ++ * Return an estimate of the number of threads matching a search ++ */ ++VALUE ++notmuch_rb_query_count_threads (VALUE self) ++{ ++ notmuch_query_t *query; ++ ++ Data_Get_Notmuch_Query (self, query); ++ ++ /* Xapian exceptions are not handled properly. ++ * (function may return 0 after printing a message) ++ * Thus there is nothing we can do here... ++ */ ++ return UINT2NUM(notmuch_query_count_threads(query)); ++} +-- +1.9.1.423.g4596e3a +