Update API for statistics (replace corpusQuery parameters with cq)

Change-Id: Ie1e9b9a6c30fd6957a372d47d09119b9a97dad43
diff --git a/Changes b/Changes
index a1d46e1..c274529 100755
--- a/Changes
+++ b/Changes
@@ -1,9 +1,10 @@
-0.35 2019-07-12
+0.35 2019-07-15
         - Added EXPERIMENTAL proxy to API route.
         - Remove deprecated api configuration
           (requires api_path instead now).
         - Deprecated 'collection' parameter in
           favor of 'cq' (#92).
+        - Update API for statistics.
 
 0.34 2019-06-26
         - Introduced guided tour (hebasta, #19).
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index eae75a8..a92d73d 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -104,7 +104,7 @@
   	//development mode:
   	var url = "http://localhost:8089/api/";
   	url  = url + "statistics";
-  	url = url + "?corpusQuery=";
+  	url = url + "?cq=";
   	url = url + collQu;
   	KorAP.API.getJSON(url, cb);
   };*/
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index 1472cd8..331f78d 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -279,7 +279,14 @@
   $url->path('statistics');
 
   # Add query
-  $url->query(corpusQuery => $v->param('cq'));
+  my $cq = $v->param('cq');
+  if ($cq) {
+    $url->query({cq => $cq});
+
+    # Temporary for backwards compatibility
+    # with Kustvakt < 0.62.1
+    $url->query({corpusQuery => $cq});
+  };
 
   $c->app->log->debug("Statistics info: $url");
 
diff --git a/t/server/mock.pl b/t/server/mock.pl
index 2b998ab..961c6ea 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -177,11 +177,11 @@
 get '/v1.0/statistics' => sub {
   my $c = shift;
   my $v = $c->validation;
-  $v->optional('corpusQuery');
+  $v->optional('cq');
 
   my @list = 'corpusinfo';
-  if ($v->param('corpusQuery')) {
-    push @list, $v->param('corpusQuery');
+  if ($v->param('cq')) {
+    push @list, $v->param('cq');
   };
   my $slug = slugify(join('_', @list));