Fix news username query should be case insensitive
This commit is contained in:
@ -105,27 +105,6 @@ module.exports = function(app) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function userStories({ body: { search = '' } = {} }, res, next) {
|
|
||||||
if (!search || typeof search !== 'string') {
|
|
||||||
return res.sendStatus(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
return app.dataSources.db.connector
|
|
||||||
.collection('story')
|
|
||||||
.find({
|
|
||||||
'author.username': search.replace('$', '')
|
|
||||||
})
|
|
||||||
.toArray(function(err, items) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
if (items && items.length !== 0) {
|
|
||||||
return res.json(items.sort(sortByRank));
|
|
||||||
}
|
|
||||||
return res.sendStatus(404);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hot(req, res) {
|
function hot(req, res) {
|
||||||
return res.render('stories/index', {
|
return res.render('stories/index', {
|
||||||
title: 'Top Stories on Camper News',
|
title: 'Top Stories on Camper News',
|
||||||
@ -225,6 +204,27 @@ module.exports = function(app) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function userStories({ body: { search = '' } = {} }, res, next) {
|
||||||
|
if (!search || typeof search !== 'string') {
|
||||||
|
return res.sendStatus(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return app.dataSources.db.connector
|
||||||
|
.collection('story')
|
||||||
|
.find({
|
||||||
|
'author.username': search.toLowerCase().replace('$', '')
|
||||||
|
})
|
||||||
|
.toArray(function(err, items) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
if (items && items.length !== 0) {
|
||||||
|
return res.json(items.sort(sortByRank));
|
||||||
|
}
|
||||||
|
return res.sendStatus(404);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getStories({ body: { search = '' } = {} }, res, next) {
|
function getStories({ body: { search = '' } = {} }, res, next) {
|
||||||
if (!search || typeof search !== 'string') {
|
if (!search || typeof search !== 'string') {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
|
Reference in New Issue
Block a user