After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740872 - Improve subfilters handling
Improve subfilters handling
Status: RESOLVED FIXED
Product: gom
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Gom Maintainers
Gom Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-28 18:53 UTC by Mathieu Bridon
Modified: 2014-12-05 17:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
filter: Free subfilters (766 bytes, patch)
2014-11-28 18:53 UTC, Mathieu Bridon
none Details | Review
filter: Make subfilters a queue (4.30 KB, patch)
2014-11-28 18:53 UTC, Mathieu Bridon
none Details | Review
filter: Add new _full variadic constructors (7.05 KB, patch)
2014-11-28 18:53 UTC, Mathieu Bridon
none Details | Review
filter: Add new _fullv constructors (6.78 KB, patch)
2014-11-28 18:54 UTC, Mathieu Bridon
none Details | Review
filter: Free subfilters (684 bytes, patch)
2014-11-29 11:16 UTC, Mathieu Bridon
committed Details | Review
filter: Make subfilters a queue (4.51 KB, patch)
2014-11-29 11:16 UTC, Mathieu Bridon
needs-work Details | Review
filter: Add new _full variadic constructors (7.05 KB, patch)
2014-11-29 11:16 UTC, Mathieu Bridon
needs-work Details | Review
filter: Add new _fullv constructors (6.78 KB, patch)
2014-11-29 11:16 UTC, Mathieu Bridon
needs-work Details | Review
filter: Make subfilters a queue (4.16 KB, patch)
2014-12-03 17:46 UTC, Mathieu Bridon
committed Details | Review
filter: Add new _full variadic constructors (7.07 KB, patch)
2014-12-03 17:47 UTC, Mathieu Bridon
committed Details | Review
filter: Add new _fullv constructors (6.76 KB, patch)
2014-12-03 17:47 UTC, Mathieu Bridon
committed Details | Review
filter: Factorize some code (1.90 KB, patch)
2014-12-03 17:48 UTC, Mathieu Bridon
committed Details | Review

Description Mathieu Bridon 2014-11-28 18:53:46 UTC
.
Comment 1 Mathieu Bridon 2014-11-28 18:53:49 UTC
Created attachment 291746 [details] [review]
filter: Free subfilters
Comment 2 Mathieu Bridon 2014-11-28 18:53:53 UTC
Created attachment 291747 [details] [review]
filter: Make subfilters a queue

Having subfilters as just two left/right values makes it impossible to
have filters with more than 2 subfilters.

But it would be very nice if we could have a single filter like:

    foo=1 AND bar=1 AND baz=0

Usign a queue for the subfilters makes this possible... and it's coming
in a future commit.
Comment 3 Mathieu Bridon 2014-11-28 18:53:58 UTC
Created attachment 291748 [details] [review]
filter: Add new _full variadic constructors

This allows AND-/OR-ing more than 2 subfilters at a time.

A unit test is also added.
Comment 4 Mathieu Bridon 2014-11-28 18:54:03 UTC
Created attachment 291749 [details] [review]
filter: Add new _fullv constructors

This is similar to the ones introduced in the previous commit, but the
argument is a NULL-temrinated array of GomFilter, rather than using
variadic functions.

A unit test is also added.
Comment 5 Mathieu Bridon 2014-11-29 11:16:08 UTC
Created attachment 291766 [details] [review]
filter: Free subfilters
Comment 6 Mathieu Bridon 2014-11-29 11:16:13 UTC
Created attachment 291767 [details] [review]
filter: Make subfilters a queue

Having subfilters as just two left/right values makes it impossible to
have filters with more than 2 subfilters.

But it would be very nice if we could have a single filter like:

    foo=1 AND bar=1 AND baz=0

Using a queue for the subfilters makes this possible... and it's coming
in a future commit.

Conflicts:
	gom/gom-filter.c
Comment 7 Mathieu Bridon 2014-11-29 11:16:18 UTC
Created attachment 291768 [details] [review]
filter: Add new _full variadic constructors

This allows AND-/OR-ing more than 2 subfilters at a time.

A unit test is also added.
Comment 8 Mathieu Bridon 2014-11-29 11:16:23 UTC
Created attachment 291769 [details] [review]
filter: Add new _fullv constructors

This is similar to the ones introduced in the previous commit, but the
argument is a NULL-temrinated array of GomFilter, rather than using
variadic functions.

A unit test is also added.
Comment 9 Mathieu Bridon 2014-11-29 11:17:16 UTC
New version of the patches attached, after some comments from slaf on IRC. :)
Comment 10 Bastien Nocera 2014-12-02 14:32:49 UTC
Review of attachment 291766 [details] [review]:

Yes.
Comment 11 Bastien Nocera 2014-12-02 14:38:22 UTC
Review of attachment 291767 [details] [review]:

"Conflicts" in the commit log? You'll need to remove that.

::: gom/gom-filter.c
@@ +316,3 @@
+      sqls = g_new (gchar *, 1 + g_queue_get_length (priv->subfilters));
+
+      i = 0;

Why not use a for loop?
len = g_queue_get_length(queue);
for (i = 0; i < len; i++) {
  f = g_queue_peek_nth (queue, i);
  ...
}

@@ +413,3 @@
    case GOM_FILTER_OR:
+      i = 0;
+      f = g_queue_peek_nth (priv->subfilters, i);

Ditto for loop.

@@ +461,3 @@
    }
 
+   if (priv->subfilters != NULL) {

No need for braces for one-liner conditionals.

@@ +462,3 @@
 
+   if (priv->subfilters != NULL) {
+      g_queue_free_full (priv->subfilters, clear_filter);

g_object_unref()?
Is there a case where you would have a null item in the queue, except a bug?
Comment 12 Bastien Nocera 2014-12-02 14:41:51 UTC
Review of attachment 291768 [details] [review]:

Looks fine otherwise.

::: gom/gom-filter.c
@@ +274,3 @@
+                          "mode", GOM_FILTER_AND,
+                          NULL);
+   filter->priv->subfilters = g_queue_new ();

A lot of copy/paste between the 2 functions, would be nice to factor that out.
Comment 13 Bastien Nocera 2014-12-02 14:42:35 UTC
Review of attachment 291769 [details] [review]:

::: gom/gom-filter.c
@@ +310,3 @@
+                          "mode", GOM_FILTER_AND,
+                          NULL);
+   filter->priv->subfilters = g_queue_new ();

Ditto about the factoring.
Comment 14 Mathieu Bridon 2014-12-02 18:30:16 UTC
Review of attachment 291766 [details] [review]:

Pushed.
Comment 15 Mathieu Bridon 2014-12-03 17:46:20 UTC
Created attachment 292080 [details] [review]
filter: Make subfilters a queue

Having subfilters as just two left/right values makes it impossible to
have filters with more than 2 subfilters.

But it would be very nice if we could have a single filter like:

    foo=1 AND bar=1 AND baz=0

Using a queue for the subfilters makes this possible... and it's coming
in a future commit.
Comment 16 Mathieu Bridon 2014-12-03 17:47:04 UTC
Created attachment 292081 [details] [review]
filter: Add new _full variadic constructors

This allows AND-/OR-ing more than 2 subfilters at a time.

A unit test is also added.
Comment 17 Mathieu Bridon 2014-12-03 17:47:41 UTC
Created attachment 292082 [details] [review]
filter: Add new _fullv constructors

This is similar to the ones introduced in the previous commit, but the
argument is a NULL-temrinated array of GomFilter, rather than using
variadic functions.

A unit test is also added.
Comment 18 Mathieu Bridon 2014-12-03 17:48:01 UTC
Created attachment 292083 [details] [review]
filter: Factorize some code
Comment 19 Bastien Nocera 2014-12-05 11:03:46 UTC
Review of attachment 292080 [details] [review]:

Looks good apart from the spaces before the brackets.
Comment 20 Bastien Nocera 2014-12-05 11:10:08 UTC
Review of attachment 292081 [details] [review]:

Same comment about the spaces before brackets.
Comment 21 Bastien Nocera 2014-12-05 11:11:08 UTC
Review of attachment 292082 [details] [review]:

Spaces. Brackets.
Comment 22 Bastien Nocera 2014-12-05 11:15:40 UTC
Review of attachment 292083 [details] [review]:

Brackets and spaces, sitting in a tree.
Comment 23 Mathieu Bridon 2014-12-05 17:17:32 UTC
All pushed with space/brackets fixed.

Attachment 292080 [details] pushed as 401d40f - filter: Make subfilters a queue
Attachment 292081 [details] pushed as fa1f603 - filter: Add new _full variadic constructors
Attachment 292082 [details] pushed as 84d9d22 - filter: Add new _fullv constructors
Attachment 292083 [details] pushed as 9e26704 - filter: Factorize some code