-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HAL #34
base: master
Are you sure you want to change the base?
HAL #34
Changes from all commits
403f255
41eaf17
a5baab4
275347e
eb02166
c7065b7
bcbf073
85527a2
f72fcaa
a3059de
1bc84a0
22cb7ce
da9f3b4
1f71bae
4f06fea
50331e1
5290673
fde998a
483bf63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
var development = { | ||
'db': { | ||
'url': 'http://localhost:9200', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
'use strict'; | ||
|
||
var getRetroId = function (type, item) { | ||
if (type==='ticket') { | ||
return item.retroId; | ||
} else { | ||
return item.id; | ||
} | ||
}; | ||
|
||
exports.getParameters = function(req) { | ||
var start = 0, | ||
limit = 10, | ||
page = 1; | ||
|
||
if (req.query.page) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably add a check that req.query.page is within 1 and N where N is top most page for the result, but I think that belongs in another review. The way it behaves now, if you have say 10 pages, and you send in ?page=30 it will create a previous link pointing to page=29 instead of redirecting you to page=10 and creating previous:9 which is probably a cleaner solution, but I consider this a edgecase for now. |
||
page = parseInt(req.query.page, 10); | ||
} | ||
|
||
if (req.query.limit) { | ||
limit = parseInt(req.query.limit, 10); | ||
} | ||
|
||
// page is a human readable iterator | ||
// start is for the machines | ||
start = (page -1) * limit; | ||
|
||
return { | ||
start: start, | ||
page: page, | ||
limit: limit | ||
}; | ||
}; | ||
|
||
exports.getItemLink = function (type, item) { | ||
var link = '/retrospectives', | ||
retroId = 0; | ||
|
||
if (!item.id) { | ||
return false; | ||
} | ||
|
||
retroId = getRetroId(type, item); | ||
link += '/' + retroId; | ||
|
||
if (type === 'ticket') { | ||
link += '/tickets/' + item.id; | ||
} | ||
return { | ||
link : link | ||
}; | ||
}; | ||
|
||
exports.getBulkLinks = function (baseUrl, parameters, results) { | ||
var links = { | ||
self: baseUrl + '?page=' + parameters.page + '&limit=' + parameters.limit, | ||
find: { | ||
href: baseUrl + '{?id}', | ||
templated: true | ||
} | ||
}; | ||
|
||
if (parameters.page - 1) { | ||
links.previous = baseUrl + '?page=' + (parameters.page - 1) + '&limit=' + parameters.limit; | ||
} | ||
|
||
if (results.length > parameters.limit) { | ||
links.next = baseUrl + '?page=' + ( parameters.page + 1) + '&limit=' + parameters.limit; | ||
} | ||
return links; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ angular.module('retrospectApp') | |
|
||
$scope.updateTickets = function () { | ||
console.log('Updating tickets.'); | ||
tickets.get({'page': $scope.page, 'limit': $scope.limit, 'retroId': $scope.retroId}, function (tickets) { | ||
tickets.get({'page': $scope.page, 'limit': $scope.limit, 'retroId': $scope.retroId}, function (response) { | ||
console.log('Got tickets'); | ||
$scope.tickets = tickets.results; | ||
$scope.tickets = response._embedded.tickets; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a rule of thumb, when you access an underscore prefixed var there's probably a better way that something could be done. Is this object member created by express-hal or you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the underscored _embed comes from express-hal. http://stateless.co/hal_specification.html I guess we need to deliver Content-Type: application/hal+json though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed Content-Type to application/hal+json There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we might be able to use http://weluse.github.io/hyperagent/ for this, but I haven't quite figured it out yet . |
||
}); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we agree on this I'll start adding some unit-tests for it. we can probably have a sitdown and discuss it tomorrow.