0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Add comments and adjust google brew for loop

This commit is contained in:
Charlie Humphreys
2022-05-26 04:40:33 +00:00
parent 55c91217ab
commit 627c52e845
2 changed files with 24 additions and 24 deletions

View File

@@ -189,19 +189,19 @@ app.get('/user/:username', async (req, res, next)=>{
console.error(err);
});
for (const brew of brews) {
const match = googleBrews?.findIndex((b)=>b.editId === brew.editId) ?? -1;
if(match !== -1) {
brew.googleId = googleBrews[match].googleId;
brew.stubbed = true;
brew.pageCount = googleBrews[match].pageCount;
brew.renderer = googleBrews[match].renderer;
brew.version = googleBrews[match].version;
googleBrews.splice(match, 1);
}
}
if(googleBrews && googleBrews.length > 0) {
for (const brew of brews) {
const match = googleBrews.findIndex((b)=>b.editId === brew.editId);
if(match !== -1) {
brew.googleId = googleBrews[match].googleId;
brew.stubbed = true;
brew.pageCount = googleBrews[match].pageCount;
brew.renderer = googleBrews[match].renderer;
brew.version = googleBrews[match].version;
googleBrews.splice(match, 1);
}
}
googleBrews = googleBrews.map((brew)=>({ ...brew, authors: [req.account.username] }));
brews = _.concat(brews, googleBrews);
}