Browse Source

Merge pull request #1813 from visuddhinanda/agile

float rank
visuddhinanda 2 years ago
parent
commit
d8e3e92dee

BIN
rpc/tulip/tulip/GPBMetadata/Tulip.php


+ 8 - 8
rpc/tulip/tulip/Mint/Tulip/V1/SearchResponse/Item.php

@@ -14,9 +14,9 @@ use Google\Protobuf\Internal\GPBUtil;
 class Item extends \Google\Protobuf\Internal\Message
 class Item extends \Google\Protobuf\Internal\Message
 {
 {
     /**
     /**
-     * Generated from protobuf field <code>int32 rank = 1;</code>
+     * Generated from protobuf field <code>float rank = 1;</code>
      */
      */
-    protected $rank = 0;
+    protected $rank = 0.0;
     /**
     /**
      * Generated from protobuf field <code>string highlight = 2;</code>
      * Generated from protobuf field <code>string highlight = 2;</code>
      */
      */
@@ -40,7 +40,7 @@ class Item extends \Google\Protobuf\Internal\Message
      * @param array $data {
      * @param array $data {
      *     Optional. Data for populating the Message object.
      *     Optional. Data for populating the Message object.
      *
      *
-     *     @type int $rank
+     *     @type float $rank
      *     @type string $highlight
      *     @type string $highlight
      *     @type int $book
      *     @type int $book
      *     @type int $paragraph
      *     @type int $paragraph
@@ -53,8 +53,8 @@ class Item extends \Google\Protobuf\Internal\Message
     }
     }
 
 
     /**
     /**
-     * Generated from protobuf field <code>int32 rank = 1;</code>
-     * @return int
+     * Generated from protobuf field <code>float rank = 1;</code>
+     * @return float
      */
      */
     public function getRank()
     public function getRank()
     {
     {
@@ -62,13 +62,13 @@ class Item extends \Google\Protobuf\Internal\Message
     }
     }
 
 
     /**
     /**
-     * Generated from protobuf field <code>int32 rank = 1;</code>
-     * @param int $var
+     * Generated from protobuf field <code>float rank = 1;</code>
+     * @param float $var
      * @return $this
      * @return $this
      */
      */
     public function setRank($var)
     public function setRank($var)
     {
     {
-        GPBUtil::checkInt32($var);
+        GPBUtil::checkFloat($var);
         $this->rank = $var;
         $this->rank = $var;
 
 
         return $this;
         return $this;

+ 9 - 4
rpc/tulip/tulip/server.php

@@ -103,10 +103,12 @@ class Greeter extends \Mint\Tulip\V1\SearchStub
         ) {
         ) {
             $total = $resultCount[0]['co'];
             $total = $resultCount[0]['co'];
         } else {
         } else {
-            console('debug', 'warning', 'result must be of type array' . $pdo->errorInfo());
+            console('error', 'result must be of type array' . $pdo->errorInfo());
             myLog()->error('result must be of type array' . $pdo->errorInfo());
             myLog()->error('result must be of type array' . $pdo->errorInfo());
             $total = 0;
             $total = 0;
         }
         }
+        console('debug', "total={$total}");
+        myLog()->info("total={$total}");
 
 
         if ($request->hasPage()) {
         if ($request->hasPage()) {
             $limit = $request->getPage()->getSize();
             $limit = $request->getPage()->getSize();
@@ -115,6 +117,7 @@ class Greeter extends \Mint\Tulip\V1\SearchStub
             $limit = 10;
             $limit = 10;
             $offset = 0;
             $offset = 0;
         }
         }
+        console('debug', "size={$limit} index={$offset}");
         $_orderBy = 'rank';
         $_orderBy = 'rank';
         switch ($_orderBy) {
         switch ($_orderBy) {
             case 'rank':
             case 'rank':
@@ -140,12 +143,13 @@ class Greeter extends \Mint\Tulip\V1\SearchStub
         $param[] = $limit;
         $param[] = $limit;
         $param[] = $offset;
         $param[] = $offset;
 
 
+
         $result = $pdo->dbSelect($query, $param);
         $result = $pdo->dbSelect($query, $param);
         //返回数据
         //返回数据
         $response = new \Mint\Tulip\V1\SearchResponse();
         $response = new \Mint\Tulip\V1\SearchResponse();
         $output = $response->getItems();
         $output = $response->getItems();
 
 
-        if ($result) {
+        if ($result !== false) {
             foreach ($result as $row) {
             foreach ($result as $row) {
                 $item = new \Mint\Tulip\V1\SearchResponse\Item;
                 $item = new \Mint\Tulip\V1\SearchResponse\Item;
                 $item->setRank($row['rank']);
                 $item->setRank($row['rank']);
@@ -155,10 +159,11 @@ class Greeter extends \Mint\Tulip\V1\SearchStub
                 $item->setContent($row['content']);
                 $item->setContent($row['content']);
                 $output[] = $item;
                 $output[] = $item;
             }
             }
+        } else {
+            console('error', "result is false");
         }
         }
 
 
-        console('debug', "total={$total}");
-        myLog()->info("total={$total}");
+
         $response->setTotal($total);
         $response->setTotal($total);
         $page = new \Mint\Tulip\V1\SearchRequest\Page;
         $page = new \Mint\Tulip\V1\SearchRequest\Page;
         $page->setIndex($offset);
         $page->setIndex($offset);