0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 06:32:39 +00:00

Cleaned up the admin routes

This commit is contained in:
Scott Tolksdorf
2017-01-06 19:21:18 -05:00
parent ca40ec5a2d
commit a26c4e2092
9 changed files with 99 additions and 86 deletions

View File

@@ -90,6 +90,21 @@ const BrewData = {
return BrewData.get({ editId });
},
//Removes all empty brews that are older than 3 days and that are shorter than a tweet
removeInvalid : (force = false) => {
const invalidBrewQuery = Brew.find({
'$where' : "this.text.length < 140",
createdAt: {
$lt: Moment().subtract(3, 'days').toDate()
}
});
if(force) return invalidBrewQuery.remove().exec();
return invalidBrewQuery.exec()
.then((objs) => {
return objs.length;
});
},
search : (query, req={}) => {
//defaults with page and count
//returns a non-text version of brews