Skip to content

Commit e30f4f3

Browse files
authored
Merge pull request #490 from datacamp/bb/package-count
[CT-3468] - bb/return total package count as header of {GET} /api/packages
2 parents e5d7777 + 149c7c8 commit e30f4f3

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ follow these steps:
5252

5353
- To deploy to stating (rdocumentation.datacamp-staging.com), merge to master
5454
- To deploy to production, add a tag which starts with `release-`
55-
5655
The rdocumentation app is hosted on DataCamp's infrastructure, on our AWS ECS cluster.
5756

5857
## What the CI does

api/controllers/PackageController.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module.exports = {
4242
* @apiSuccess {Integer} versions.maintainer_id Id of the maintainer of the package version
4343
* @apiSuccess {String} type Always 'package'
4444
*/
45-
4645
findByName: function(req, res) {
4746
var packageName = req.param('name');
4847

@@ -85,8 +84,10 @@ module.exports = {
8584
* @api {get} /packages List all packages
8685
* @apiName Get Packages
8786
* @apiGroup Package
88-
* @apiDescription Return an array of package object containing listed attributes
87+
* @apiDescription Return an array of package object containing listed attributes and total number of package objects header.
8988
*
89+
* @apiHeader (Header) {String} x-total-count total count of packages.
90+
*
9091
* @apiParam {String} limit the number to use when limiting records to send back (useful for pagination)
9192
* @apiParam {String} skip the number of records to skip when limiting (useful for pagination)
9293
* @apiParam {String} sort the order of returned records, e.g. `name ASC` or `name DESC`
@@ -106,15 +107,16 @@ module.exports = {
106107
var limit = Utils.parseLimit(req);
107108
var offset = Utils.parseSkip(req);
108109
var sort = Utils.parseSort(req);
109-
var criteria = Utils.parseCriteria(req);
110+
var criteria = Utils.parseCriteria(req);
110111

111112
Package.findAll({
112-
where: criteria,
113113
limit: limit,
114+
where: criteria,
114115
offset: offset,
115116
order: sort,
116117
include: []
117118
}).then(function(packages) {
119+
res.set('X-Total-Count', packages.length);
118120
return res.json(packages);
119121
}).catch(function(err) {
120122
return res.negotiate(err);

config/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
module.exports.routes = {
2424
// Homepage
2525
'get /': 'HomeController.index',
26-
'get /status': 'HomeController.status',
26+
'get /status': 'HomeController.status',
2727

2828
// Authentication
2929
'get /login': 'AuthController.login',

views/layout.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<% } %>
5959

6060
<!--TEMPLATES-->
61-
61+
6262
<!--TEMPLATES END-->
6363

6464
<script src="<%= protocol %>//code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>

0 commit comments

Comments
 (0)