Skip to content

Commit

Permalink
fixing comment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kagaramag committed Jul 26, 2019
1 parent 7789e96 commit b17dee2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controllers/ArticleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class ArticleController {
if (articles.length >= 1 && !!articles) {
return res.status(status.OK).send({
articles,
articlesCount: 3 // helpers.articles.counter('published')
articlesCount: await helpers.articles.counter('published')
});
}
return res.status(status.NOT_FOUND).send({ message: 'No articles found' });
Expand Down
1 change: 0 additions & 1 deletion src/controllers/CommentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class CommentController {
const { articleSlug } = req.params;
const { body } = req.body;
const response = await comment.create({ articleSlug, userId, body });
console.log('@#$', response.id);
const createdComment = await comment.getSingle(response.id);
return res.status(status.CREATED).json({
message: 'Comment successfully created',
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/articles/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import { Article } from '../../queries';

export default async (status) => {
const counter = await Article.getArticlesCounter(status);
console.log('@#$', counter.article);
return 4;
return counter;
};
5 changes: 2 additions & 3 deletions src/queries/articles/getArticlesCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import db from '../../models';
*/
export default async (status) => {
let response = [];
response = await db.Article.findAll({
response = await db.Article.count({
where: { status },
logging: false,
attributes: ['id']
logging: false
});
return response;
};

0 comments on commit b17dee2

Please sign in to comment.