Jelajahi Sumber

Add /api/boards_count endpoint for statistics

Kyâne 4 tahun lalu
induk
melakukan
bcf5a586c7
3 mengubah file dengan 51 tambahan dan 1 penghapusan
  1. 24 0
      models/boards.js
  2. 6 1
      public/api/wekan.html
  3. 21 0
      public/api/wekan.yml

+ 24 - 0
models/boards.js

@@ -1700,6 +1700,30 @@ if (Meteor.isServer) {
     }
     }
   });
   });
 
 
+  /**
+   * @operation get_boards_count
+   * @summary Get public and private boards count
+   *
+   * @return_type {private: integer, public: integer}
+   */
+  JsonRoutes.add('GET', '/api/boards_count', function(req, res) {
+    try {
+      Authentication.checkUserId(req.userId);
+      JsonRoutes.sendResult(res, {
+        code: 200,
+        data: {
+          private: Boards.find({ permission: 'private' }).count(),
+          public: Boards.find({ permission: 'public' }).count(),
+        },
+      });
+    } catch (error) {
+      JsonRoutes.sendResult(res, {
+        code: 200,
+        data: error,
+      });
+    }
+  });
+
   /**
   /**
    * @operation get_board
    * @operation get_board
    * @summary Get the board with that particular ID
    * @summary Get the board with that particular ID

+ 6 - 1
public/api/wekan.html

@@ -1566,7 +1566,12 @@ var n=this.pipeline.run(e.tokenizer(t)),r=new e.Vector,i=[],o=this._fields.reduc
                     <a href="#get_public_boards" class="toc-h2 toc-link" data-title="get_public_boards">get_public_boards</a>
                     <a href="#get_public_boards" class="toc-h2 toc-link" data-title="get_public_boards">get_public_boards</a>
                     
                     
                   </li>
                   </li>
-                
+
+                  <li>
+                    <a href="#get_boards_count" class="toc-h2 toc-link" data-title="get_boards_count">get_boards_count</a>
+
+                  </li>
+
                   <li>
                   <li>
                     <a href="#new_board" class="toc-h2 toc-link" data-title="new_board">new_board</a>
                     <a href="#new_board" class="toc-h2 toc-link" data-title="new_board">new_board</a>
                     
                     

+ 21 - 0
public/api/wekan.yml

@@ -245,6 +245,27 @@ paths:
                 type: string
                 type: string
               defaultSwimlaneId:
               defaultSwimlaneId:
                 type: string
                 type: string
+  /api/boards_count:
+    get:
+      operationId: get_boards_count
+      summary: Get boards count
+      tags:
+        - Boards
+      produces:
+        - application/json
+      security:
+          - UserSecurity: []
+      responses:
+        '200':
+          description: |-
+            200 response
+          schema:
+            type: object
+            properties:
+              private:
+                type: integer
+              public:
+                type: integer
   /api/boards/{board}:
   /api/boards/{board}:
     get:
     get:
       operationId: get_board
       operationId: get_board