[libgdata] tasks: Fix pagination in Google Tasks API



commit a6b98081e45670d1b39e80afe9b1aa34fc536b2a
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Feb 6 10:04:17 2017 +0100

    tasks: Fix pagination in Google Tasks API
    
    The pageToken URI parameter was never being appended to queries, so they
    could never retrieve more than the first page of results.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775813

 gdata/services/tasks/gdata-tasks-query.c |   10 ++++++----
 gdata/tests/tasks.c                      |    9 +++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/gdata/services/tasks/gdata-tasks-query.c b/gdata/services/tasks/gdata-tasks-query.c
index f566605..627dc86 100644
--- a/gdata/services/tasks/gdata-tasks-query.c
+++ b/gdata/services/tasks/gdata-tasks-query.c
@@ -271,6 +271,11 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
 {
        GDataTasksQueryPrivate *priv = GDATA_TASKS_QUERY (self)->priv;
 
+       /* Chain up to the parent class. This adds a load of irrelevant query
+        * parameters, but they’re harmless. Importantly, it adds pagination
+        * support. */
+       GDATA_QUERY_CLASS (gdata_tasks_query_parent_class)->get_query_uri (self, feed_uri, query_uri, 
params_started);
+
        #define APPEND_SEP g_string_append_c (query_uri, (*params_started == FALSE) ? '?' : '&'); 
*params_started = TRUE;
 
        if (gdata_query_get_max_results (GDATA_QUERY (self)) > 0) {
@@ -349,10 +354,7 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
                g_string_append (query_uri, "showHidden=false");
        }
 
-       /* We don't chain up with parent class get_query_uri because it uses
-        *  GData protocol parameters and they aren't compatible with newest API family
-        */
-        #undef APPEND_SEP
+       #undef APPEND_SEP
 }
 
 /**
diff --git a/gdata/tests/tasks.c b/gdata/tests/tasks.c
index 7535c97..2e9a03e 100644
--- a/gdata/tests/tasks.c
+++ b/gdata/tests/tasks.c
@@ -121,7 +121,10 @@ test_query_uri (void)
                                               "http://example.com";);
        g_assert_cmpstr (query_uri, ==,
                         "http://example.com";
-                        "?maxResults=10"
+                        /* FIXME: First two are outdated fallbacks */
+                        "?updated-min=1970-01-01T01:53:09Z"
+                        "&max-results=10"
+                        "&maxResults=10"
                         "&updatedMin=1970-01-01T01:53:09Z"
                         "&completedMin=1970-01-01T01:34:38Z"
                         "&completedMax=1970-01-01T00:20:34Z"
@@ -147,7 +150,9 @@ test_query_uri (void)
                                               "http://example.com";);
        g_assert_cmpstr (query_uri, ==,
                         "http://example.com";
-                        "?maxResults=10"
+                        "?updated-min=1970-01-01T01:53:09Z"
+                        "&max-results=10"
+                        "&maxResults=10"
                         "&updatedMin=1970-01-01T01:53:09Z"
                         "&completedMin=1970-01-01T01:34:38Z"
                         "&completedMax=1970-01-01T00:20:34Z"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]