ruby: Add wrapper for notmuch_query_count_threads

This commit is contained in:
Wael M. Nasreddine 2014-05-10 14:40:11 -07:00 committed by David Bremner
parent c67587f003
commit 0629afeb26
3 changed files with 23 additions and 0 deletions

View file

@ -231,6 +231,9 @@ notmuch_rb_query_search_messages (VALUE self);
VALUE VALUE
notmuch_rb_query_count_messages (VALUE self); notmuch_rb_query_count_messages (VALUE self);
VALUE
notmuch_rb_query_count_threads (VALUE self);
/* threads.c */ /* threads.c */
VALUE VALUE
notmuch_rb_threads_destroy (VALUE self); notmuch_rb_threads_destroy (VALUE self);

View file

@ -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_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, "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_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 * Document-class: Notmuch::Threads

View file

@ -182,3 +182,22 @@ notmuch_rb_query_count_messages (VALUE self)
*/ */
return UINT2NUM(notmuch_query_count_messages(query)); 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));
}