Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
stolksdorf committed Dec 6, 2018
1 parent 52c0462 commit bf21c3d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion client/admin/admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Admin = createClass({
<hr />
<BrewCleanup />
</div>
</div>
</div>;
}
});

Expand Down
20 changes: 10 additions & 10 deletions client/admin/brewCleanup/brewCleanup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ const BrewCleanup = createClass({
count : 0,

pending : false,
primed : false,
err : null
primed : false,
err : null
};
},
prime(){
this.setState({ pending: true });

request.get('/admin/cleanup')
.then((res)=> this.setState({count : res.body.count, primed : true }))
.catch((err)=>this.setState({ error : err }))
.finally(()=>this.setState({ pending : false }))
.then((res)=>this.setState({ count: res.body.count, primed: true }))
.catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ pending: false }));
},
cleanup(){
this.setState({ pending: true });

request.post('/admin/cleanup')
.then((res)=> this.setState({count : res.body.count }))
.catch((err)=>this.setState({ error : err }))
.finally(()=>this.setState({ pending : false, primed : false }))
.then((res)=>this.setState({ count: res.body.count }))
.catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ pending: false, primed: false }));
},
renderPrimed(){
if(!this.state.primed) return;

if(!this.state.count){
return <div className='removeBox'>No Matching Brews found.</div>
return <div className='removeBox'>No Matching Brews found.</div>;
}
return <div className='removeBox'>
<button onClick={this.cleanup} className='remove'>
Expand All @@ -49,7 +49,7 @@ const BrewCleanup = createClass({
}
</button>
<span>Found {this.state.count} Brews that could be removed. </span>
</div>
</div>;
},
render(){
return <div className='BrewCleanup'>
Expand Down
18 changes: 9 additions & 9 deletions client/admin/brewLookup/brewLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ const BrewLookup = createClass({
},
getInitialState() {
return {
query : '',
foundBrew : null,
searching : false,
error : null
query : '',
foundBrew : null,
searching : false,
error : null
};
},
handleChange(e){
this.setState({ query : e.target.value });
this.setState({ query: e.target.value });
},
lookup(){
this.setState({ searching: true, error: null });

request.get(`/admin/lookup/${this.state.query}`)
.then((res)=> this.setState({foundBrew : res.body}))
.catch((err)=>this.setState({ error : err }))
.finally(()=>this.setState({ searching : false }))
.then((res)=>this.setState({ foundBrew: res.body }))
.catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ searching: false }));
},

renderFoundBrew(){
Expand Down Expand Up @@ -61,7 +61,7 @@ const BrewLookup = createClass({
<input type='text' value={this.state.query} onChange={this.handleChange} placeholder='edit or share id' />
<button onClick={this.lookup}>
<i className={cx('fa', {
'fa-search' : !this.state.searching,
'fa-search' : !this.state.searching,
'fa-spin fa-spinner' : this.state.searching,
})} />
</button>
Expand Down
8 changes: 4 additions & 4 deletions client/admin/stats/stats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const Stats = createClass({
totalBrews : 0
},
fetching : false
}
};
},
componentDidMount(){
this.fetchStats();
},
fetchStats(){
this.setState({ fetching : true})
this.setState({ fetching: true });
request.get('/admin/stats')
.then((res)=> this.setState({ stats : res.body }))
.finally(()=>this.setState({fetching : false}));
.then((res)=>this.setState({ stats: res.body }))
.finally(()=>this.setState({ fetching: false }));
},
render(){
return <div className='Stats'>
Expand Down
20 changes: 10 additions & 10 deletions server/admin.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ const junkBrewQuery = HomebrewModel.find({
router.get('/admin/cleanup', mw.adminOnly, (req, res)=>{
junkBrewQuery.exec((err, objs)=>{
if(err) return res.status(500).send(err);
return res.json({ count : objs.length });
return res.json({ count: objs.length });
});
});
/* Removes all empty brews that are older than 3 days and that are shorter than a tweet */
router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
junkBrewQuery.remove().exec((err, objs)=>{
if(err) return res.status(500).send(err);
return res.json({ count : objs.length });
return res.json({ count: objs.length });
});
})
});

/* Searches for matching edit or share id, also attempts to partial match */
router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
HomebrewModel.findOne({ $or : [
{ editId: { '$regex': req.params.id, '$options': 'i' } },
{ editId: { '$regex': req.params.id, '$options': 'i' } },
{ shareId: { '$regex': req.params.id, '$options': 'i' } },
]}).exec((err, brew)=>{
] }).exec((err, brew)=>{
return res.json(brew);
});
});
Expand All @@ -61,16 +61,16 @@ router.get('/admin/stats', mw.adminOnly, (req, res)=>{
HomebrewModel.count({}, (err, count)=>{
return res.json({
totalBrews : count
})
})
});
});
});

router.get('/admin', mw.adminOnly, (req, res)=>{
render('admin', templateFn, {
url : req.originalUrl
url : req.originalUrl
})
.then((page)=>res.send(page))
.catch((err)=>res.sendStatus(500))
.then((page)=>res.send(page))
.catch((err)=>res.sendStatus(500));
});

module.exports = router;

0 comments on commit bf21c3d

Please sign in to comment.