Explorar o código

add isTenResults

zahmis %!s(int64=5) %!d(string=hai) anos
pai
achega
658c7fc6f3
Modificáronse 1 ficheiros con 10 adicións e 6 borrados
  1. 10 6
      src/server/service/bolt.js

+ 10 - 6
src/server/service/bolt.js

@@ -171,9 +171,14 @@ class BoltService {
     const keywords = keywordsArr.join(' ');
     const keywords = keywordsArr.join(' ');
 
 
     const { searchService } = this.crowi;
     const { searchService } = this.crowi;
-    const options = { limit: 10, offset };
+    const options = { limit: 11, offset };
     const results = await searchService.searchKeyword(keywords, null, {}, options);
     const results = await searchService.searchKeyword(keywords, null, {}, options);
+    const tenResults = results.data.slice(0, 10);
 
 
+    let isTenResults = false;
+    if (results.data.length === 10) {
+      isTenResults = true;
+    }
 
 
     // no search results
     // no search results
     if (results.data.length === 0) {
     if (results.data.length === 0) {
@@ -203,18 +208,18 @@ class BoltService {
       return;
       return;
     }
     }
 
 
-    const resultPaths = results.data.map((data) => {
+    const resultPaths = tenResults.map((data) => {
       return data._source.path;
       return data._source.path;
     });
     });
 
 
     return {
     return {
-      resultPaths, offset, keywords,
+      resultPaths, offset, keywords, isTenResults,
     };
     };
   }
   }
 
 
   async showEphemeralSearchResults(command, args, offsetNum) {
   async showEphemeralSearchResults(command, args, offsetNum) {
     const {
     const {
-      resultPaths, offset, keywords,
+      resultPaths, offset, keywords, isTenResults,
     } = await this.getSearchResultPaths(command, args, offsetNum);
     } = await this.getSearchResultPaths(command, args, offsetNum);
 
 
     if (resultPaths == null) {
     if (resultPaths == null) {
@@ -246,9 +251,8 @@ class BoltService {
 
 
     const keywordsAndDesc = `keyword(s) : "${keywords}" \n ${searchResultsDesc}.`;
     const keywordsAndDesc = `keyword(s) : "${keywords}" \n ${searchResultsDesc}.`;
 
 
-
     try {
     try {
-      if (searchResultsNum < 10) {
+      if (searchResultsNum < 10 || isTenResults) {
         return await this.client.chat.postEphemeral({
         return await this.client.chat.postEphemeral({
           channel: command.channel_id,
           channel: command.channel_id,
           user: command.user_id,
           user: command.user_id,