? views-add-filter-comment-depth.patch
Index: modules/comment.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/comment.views.inc,v
retrieving revision 1.30
diff -u -p -r1.30 comment.views.inc
--- modules/comment.views.inc	6 Feb 2009 20:58:18 -0000	1.30
+++ modules/comment.views.inc	12 Feb 2009 20:28:58 -0000
@@ -204,6 +204,11 @@ function comment_views_data() {
       'help' => t('Display the depth of the comment if it is threaded.'),
       'handler' => 'views_handler_field_comment_depth',
     ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_comment_depth',
+      'title' => t('Depth'),
+      'help' => t('Depth of the comment if it is threaded.'),
+    ),
     'sort' => array(
       'title' => t('Thread'),
       'help' => t('Sort by the threaded order. This will keep child comments together with their parents.'),
@@ -477,6 +482,9 @@ function comment_views_handlers() {
       'views_handler_filter_comment_user_uid' => array(
         'parent' => 'views_handler_filter_user_name',
       ),
+      'views_handler_filter_comment_depth' => array(
+        'parent' => 'views_handler_filter_numeric',
+      ),
 
       // argument handlers
       'views_handler_argument_comment_user_uid' => array(
Index: modules/comment/views_handler_filter_comment_depth.inc
===================================================================
RCS file: modules/comment/views_handler_filter_comment_depth.inc
diff -N modules/comment/views_handler_filter_comment_depth.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/comment/views_handler_filter_comment_depth.inc	12 Feb 2009 20:28:58 -0000
@@ -0,0 +1,23 @@
+<?php
+// $Id: $
+/**
+ * Filter handler for comment depth
+ */
+class views_handler_filter_comment_depth extends views_handler_filter_numeric {
+  function query() {
+
+    $this->ensure_my_table();
+
+    $field = "(LENGTH(" . 
+             $this->table_alias . 
+             ".thread) - LENGTH(REPLACE(" .
+             $this->table_alias . 
+             ".thread, '.', '')))";
+
+    $info = $this->operators();
+    if (!empty($info[$this->operator]['method'])) {
+      $this->{$info[$this->operator]['method']}($field);
+    }
+
+  }
+}
