0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00
This commit is contained in:
Trevor Buckner
2022-12-10 13:31:57 -05:00
parent d0a1ef9571
commit b72acd9e59
2 changed files with 7 additions and 17 deletions

View File

@@ -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>

View File

@@ -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
};
}