mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Merge pull request #4424 from helioguardabaxo/master
Add get list and board cards count to API
This commit is contained in:
commit
bf023e8218
1 changed files with 66 additions and 0 deletions
|
|
@ -3288,6 +3288,72 @@ if (Meteor.isServer) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation get_board_cards_count
|
||||||
|
* @summary Get a cards count to a board
|
||||||
|
*
|
||||||
|
* @param {string} boardId the board ID
|
||||||
|
* @return_type {board_cards_count: integer}
|
||||||
|
*/
|
||||||
|
JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const paramBoardId = req.params.boardId;
|
||||||
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: {
|
||||||
|
board_cards_count: Cards.find({
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
}).count(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation get_list_cards_count
|
||||||
|
* @summary Get a cards count to a list
|
||||||
|
*
|
||||||
|
* @param {string} boardId the board ID
|
||||||
|
* @param {string} listId the List ID
|
||||||
|
* @return_type {list_cards_count: integer}
|
||||||
|
*/
|
||||||
|
JsonRoutes.add('GET', '/api/boards/:boardId/lists/:listId/cards_count', function(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const paramBoardId = req.params.boardId;
|
||||||
|
const paramListId = req.params.listId;
|
||||||
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: {
|
||||||
|
list_cards_count: Cards.find({
|
||||||
|
boardId: paramBoardId,
|
||||||
|
listId: paramListId,
|
||||||
|
archived: false,
|
||||||
|
}).count(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note for the JSDoc:
|
* Note for the JSDoc:
|
||||||
* 'list' will be interpreted as the path parameter
|
* 'list' will be interpreted as the path parameter
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue