add some test + css adjustments
authorymh <ymh.work@gmail.com>
Tue, 15 Nov 2016 23:35:59 +0100
changeset 427 695111d1eec9
parent 426 d8ae6c0c0a0a
child 428 76a47f714766
add some test + css adjustments
cms/app-client/app/styles/app.scss
cms/app-client/app/styles/tabs/chrono.scss
cms/app-client/app/styles/tabs/langues.scss
server/src/tests/Controllers/DateStatsControllerTest.php
--- a/cms/app-client/app/styles/app.scss	Tue Nov 15 18:27:17 2016 +0100
+++ b/cms/app-client/app/styles/app.scss	Tue Nov 15 23:35:59 2016 +0100
@@ -36,6 +36,7 @@
 #corpus-app {
     font-family: sans-serif;
     font-size: 12px;
+    line-height: initial;
 }
 
 #corpus-app {
--- a/cms/app-client/app/styles/tabs/chrono.scss	Tue Nov 15 18:27:17 2016 +0100
+++ b/cms/app-client/app/styles/tabs/chrono.scss	Tue Nov 15 23:35:59 2016 +0100
@@ -1,7 +1,7 @@
 #tabs-chrono p {
     padding: 0px 20px;
     text-align: center;
-    margin: 25px 0px 25px 0px;
+    margin: 15px 0px;
     line-height: 22px;
     color: $corpus-black;
 }
--- a/cms/app-client/app/styles/tabs/langues.scss	Tue Nov 15 18:27:17 2016 +0100
+++ b/cms/app-client/app/styles/tabs/langues.scss	Tue Nov 15 23:35:59 2016 +0100
@@ -91,6 +91,6 @@
 #tabs-langues .color-gradient-wrapper .color-gradient {
     position: relative;
     width: 100%;
-    height: 1.75em;
+    height: 27px;
     font-size: 0.75em;
 }
--- a/server/src/tests/Controllers/DateStatsControllerTest.php	Tue Nov 15 18:27:17 2016 +0100
+++ b/server/src/tests/Controllers/DateStatsControllerTest.php	Tue Nov 15 23:35:59 2016 +0100
@@ -42,6 +42,29 @@
                 ]
             ]
         ];
+
+        $this->ES_QUERY_MINMAX = [
+            'index' => 'corpus',
+            'body' => [
+                "size" => 0,
+                "query" => [ "match_all" => (object) null ],
+                "aggs" => [
+                    "datestats" => [
+                        "nested"=> [
+                            "path" => "creation_years"
+                        ],
+                        "aggs" => [
+                            "minyear" => [
+                                "min" => [ "field"=> "creation_years.year" ]
+                            ],
+                            "maxyear" => [
+                                "max" => [ "field"=> "creation_years.year" ]
+                            ]
+                        ]
+                    ]
+                ]
+            ]
+        ];
     }
 
     public function tearDown() {
@@ -147,4 +170,73 @@
             ]]);
     }
 
+
+    public function testMinMaxQuery() {
+
+        Es::shouldReceive('search')
+                ->once()
+                ->with($this->ES_QUERY_MINMAX)
+                ->andReturn(json_decode('{
+                    "took" : 708,
+                    "timed_out" : false,
+                    "_shards" : {
+                        "total" : 1,
+                        "successful" : 1,
+                        "failed" : 0
+                    },
+                    "hits" : {
+                        "total" : 0,
+                        "max_score" : 0.0,
+                        "hits" : [ ]
+                    },
+                    "aggregations" : {
+                        "datestats" : {
+                            "doc_count" : 0,
+                            "maxyear" : {
+                                "value" : null
+                            },
+                            "minyear" : {
+                                "value" : null
+                            }
+                        }
+                    }
+                }', true));
+        $this->get('/api/v1/stats/dateminmax/')->assertTrue($this->response->isOk(), $this->response->content());
+        $this->seeJsonEquals(["dateminmax" => [0, 0]]);
+    }
+
+    public function testMinMaxResult() {
+
+        Es::shouldReceive('search')
+                ->once()
+                ->with($this->ES_QUERY_MINMAX)
+                ->andReturn(json_decode('{
+                    "took" : 708,
+                    "timed_out" : false,
+                    "_shards" : {
+                        "total" : 1,
+                        "successful" : 1,
+                        "failed" : 0
+                    },
+                    "hits" : {
+                        "total" : 3375,
+                        "max_score" : 0.0,
+                        "hits" : [ ]
+                    },
+                    "aggregations" : {
+                        "datestats" : {
+                            "doc_count" : 3727,
+                            "maxyear" : {
+                                "value" : 2015.0
+                            },
+                            "minyear" : {
+                                "value" : 1948.0
+                            }
+                        }
+                    }
+                }', true));
+        $this->get('/api/v1/stats/dateminmax/')->assertTrue($this->response->isOk(), $this->response->content());
+        $this->seeJsonEquals(["dateminmax" => [ 1948, 2015 ]]);
+    }
+
 }