Skip to content

Commit

Permalink
SWIK-2441 include_previous_revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaun committed Oct 17, 2018
1 parent de8d767 commit de8ccf7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions application/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,34 @@ let self = module.exports = {
let slideIdArray = [];
let deckIdArray = [];

const all_revisions = request.query.all_revisions;
const include_previous_revisions = request.query.include_previous_revisions;
arrayOfDecksAndSlides.forEach((deckOrSlide) => {
const id = (all_revisions === 'true') ? new RegExp('^' + deckOrSlide.id.split('-')[0]) : deckOrSlide.id;

if (deckOrSlide.type === 'slide') {
slideIdArray.push(id);
slideIdArray.push(deckOrSlide.id);
} else {
deckIdArray.push(id);
deckIdArray.push(deckOrSlide.id);
}
if (include_previous_revisions === 'true') {
let idSplit = deckOrSlide.id.split('-');
let id = idSplit[0];
let revId = (idSplit.length > 1) ? parseInt(idSplit[1]) : 0;

//add id without revision
if (deckOrSlide.type === 'slide') {
slideIdArray.push(id);
} else {
deckIdArray.push(id);
}

//add ids for previous revisions
for (let i = 1; i < revId; i++) {
if (deckOrSlide.type === 'slide') {
slideIdArray.push(id + '-' + String(i));
} else {
deckIdArray.push(id + '-' + String(i));
}
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion application/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function(server) {
},
query: {
metaonly: Joi.string().description('Set to true to return only metadata without the list of comments'),
all_revisions: Joi.string().description('Set to true to search for comments regardles of the content revision')
include_previous_revisions: Joi.string().description('Set to true to get comments for current and all previous revisions of content')
}
},
tags: ['api'],
Expand Down

0 comments on commit de8ccf7

Please sign in to comment.