Kaynağa Gözat

add isTenResults

zahmis 5 yıl önce
ebeveyn
işleme
658c7fc6f3
1 değiştirilmiş dosya ile 10 ekleme ve 6 silme
  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 { searchService } = this.crowi;
-    const options = { limit: 10, offset };
+    const options = { limit: 11, offset };
     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
     if (results.data.length === 0) {
@@ -203,18 +208,18 @@ class BoltService {
       return;
     }
 
-    const resultPaths = results.data.map((data) => {
+    const resultPaths = tenResults.map((data) => {
       return data._source.path;
     });
 
     return {
-      resultPaths, offset, keywords,
+      resultPaths, offset, keywords, isTenResults,
     };
   }
 
   async showEphemeralSearchResults(command, args, offsetNum) {
     const {
-      resultPaths, offset, keywords,
+      resultPaths, offset, keywords, isTenResults,
     } = await this.getSearchResultPaths(command, args, offsetNum);
 
     if (resultPaths == null) {
@@ -246,9 +251,8 @@ class BoltService {
 
     const keywordsAndDesc = `keyword(s) : "${keywords}" \n ${searchResultsDesc}.`;
 
-
     try {
-      if (searchResultsNum < 10) {
+      if (searchResultsNum < 10 || isTenResults) {
         return await this.client.chat.postEphemeral({
           channel: command.channel_id,
           user: command.user_id,