Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #153 from PREreview/ddoc-bug-fix
Browse files Browse the repository at this point in the history
Fixed a little bug on the ddoc initialization
  • Loading branch information
jheretic authored Jul 29, 2020
2 parents 1f342d5 + 459eec5 commit 6a361ce
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 100 deletions.
56 changes: 1 addition & 55 deletions src/ddocs/ddoc-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ const ddoc = {
hasReviews: 'keyword',
hasRequests: 'keyword',
hasData: 'keyword',
hasCode: 'keyword',
hasOthersRec: 'keyword',
hasPeerRec: 'keyword'
hasCode: 'keyword'
}
},
index: function(doc) {
Expand Down Expand Up @@ -270,65 +268,13 @@ const ddoc = {
}
return false;
});
console.log("....hasCode", reviewsWithCode)


var hasCode =
reviewsWithCode.length && reviewsWithCode.length >= threshold;
index('hasCode', hasCode ? 'true' : 'false', {
facet: true
});

// has recommendations to others
var reviewsWithRecs = reviewActions.filter(function (action) {
if (action.resultReview && action.resultReview.reviewAnswer) {
var answers = action.resultReview.reviewAnswer;

for (var i = 0; i < answers.length; i++) {
var answer = answers[i];
if (answer.parentItem) {
var questionId =
answer.parentItem['@id'] || answer.parentItem;
if (questionId === 'question:ynRecommend') {
return (answer.text || '').toLowerCase().trim() === 'yes';
}
}
}
}
return false;
});

var hasOthersRec =
reviewsWithRecs.length && reviewsWithRecs.length >= threshold;
index('hasOthersRec', hasOthersRec ? 'true' : 'false', {
facet: true
});

// has recommendations for peer review
var reviewsWithPeers = reviewActions.filter(function (action) {
if (action.resultReview && action.resultReview.reviewAnswer) {
var answers = action.resultReview.reviewAnswer;

for (var i = 0; i < answers.length; i++) {
var answer = answers[i];
if (answer.parentItem) {
var questionId =
answer.parentItem['@id'] || answer.parentItem;
if (questionId === 'question:ynPeerReview') {
return (answer.text || '').toLowerCase().trim() === 'yes';
}
}
}
}
return false;
});

var hasPeerRec =
reviewsWithPeers.length && reviewsWithPeers.length >= threshold;
index('hasPeerRec', hasPeerRec ? 'true' : 'false', {
facet: true
});

// subjectName
var subjectCountMap = {};
reviewActions.forEach(function(action) {
Expand Down
6 changes: 0 additions & 6 deletions src/ddocs/ddoc-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ const ddoc = {
},
reduce: '_count'
}
},

indexes: {
index: function(doc) {
return doc;
}
}
};

Expand Down
39 changes: 0 additions & 39 deletions src/routes/api-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,45 +152,6 @@ router.get(
}
);

// feed of useful things
// router.get(
// '/feed',
// cors(),
// parseQuery,
// cashe(req => req.query.key),
// (req, res, next) => {
// res.setHeader('content-type', 'application/json');
// let hasErrored = false;

// const s = req.db.streamActions(omit(req.query, ['key']));
// s.on('response', response => {
// console.log("HELLO??????")
// res.status(response.statusCode);
// });
// s.on('error', err => {
// if (!hasErrored) {
// hasErrored = true;
// next(err);
// }

// try {
// s.destroy();
// } catch (err) {
// // noop
// }
// });

// s.pipe(
// concatStream(buffer => {
// req.cache(JSON.parse(buffer));
// })
// );

// s.pipe(res);
// }
// )


/**
* Search for roles
*/
Expand Down

0 comments on commit 6a361ce

Please sign in to comment.