mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 18:32:41 +00:00
cleanup
This commit is contained in:
@@ -57,7 +57,7 @@ const AccountPage = createClass({
|
||||
<p><strong>Linked to Google: </strong> {this.props.uiItems.googleId ? 'YES' : 'NO'}</p>
|
||||
{this.props.uiItems.googleId &&
|
||||
<p>
|
||||
<strong>Brews on Google Drive: </strong> {this.props.uiItems.googleCount ? this.props.uiItems.googleCount : <>Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a></>}
|
||||
<strong>Brews on Google Drive: </strong> {this.props.uiItems.googleCount ?? <>Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a></>}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -361,30 +361,20 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
|
||||
}
|
||||
}
|
||||
|
||||
const aggregateQuery =[{
|
||||
'$match' : {
|
||||
'googleId' : {
|
||||
'$exists' : false
|
||||
},
|
||||
'authors' : req.account.username
|
||||
}
|
||||
}, {
|
||||
'$count' : 'total'
|
||||
}];
|
||||
const mongoCount = [];
|
||||
mongoCount.push(...await HomebrewModel.aggregate(aggregateQuery)
|
||||
const query = { authors: req.account.username, googleId: { $exists: false } };
|
||||
const mongoCount = await HomebrewModel.countDocuments(query)
|
||||
.catch((err)=>{
|
||||
mongoCount = 0;
|
||||
console.log(err);
|
||||
}));
|
||||
mongoCount.push({ total: 0 });
|
||||
});
|
||||
|
||||
data.uiItems = {
|
||||
username : req.account.username,
|
||||
issued : req.account.issued,
|
||||
mongoCount : mongoCount[0]?.total.toString(),
|
||||
googleId : Boolean(req.account.googleId),
|
||||
authCheck : Boolean(req.account.googleId && auth.credentials.access_token),
|
||||
googleCount : googleCount?.length.toString() || null
|
||||
mongoCount : mongoCount,
|
||||
googleCount : googleCount?.length
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user