ss import: clarify log and output when no papers found
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 34s Details

This commit is contained in:
Ladd Hoffman 2024-04-23 12:30:11 -05:00
parent 1948e81733
commit afbfc0c0f2
2 changed files with 13 additions and 5 deletions

View File

@ -231,7 +231,11 @@ module.exports = async (req, res) => {
const papers = await fetchAuthorPapers(authorId);
console.log('papers count:', papers.length);
const result = await Promise.mapSeries(papers, importPaper);
console.log(`Added posts for ${result.length} papers by author ${authorId}`);
if (result.length) {
console.log(`Added posts for ${result.length} papers by author ${authorId}`);
}
res.json(result);
} else {
res.status(400).end();
}
};

View File

@ -13,10 +13,14 @@ function ImportPapersByAuthor() {
.catch((error) => {
setStatus(`Error: ${error.response?.data ?? error.message}`);
});
const getStatus = ({ paperId, postId, alreadyAdded }) => (alreadyAdded
? `Paper ${paperId} was already imported as post ${postId}`
: `Imported paper ${paperId} as post ${postId}`);
setStatus(results.map(getStatus).join('\n'));
if (results?.length) {
const getStatus = ({ paperId, postId, alreadyAdded }) => (alreadyAdded
? `Paper ${paperId} was already imported as post ${postId}`
: `Imported paper ${paperId} as post ${postId}`);
setStatus(results.map(getStatus).join('\n'));
} else {
setStatus(`Found 0 papers by author ${authorId}`);
}
};
return (