Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ft-165412937] add reading stats #68

Merged
merged 1 commit into from
Jun 11, 2019

Conversation

luc-tuyishime
Copy link
Contributor

@luc-tuyishime luc-tuyishime commented Jun 7, 2019

What does this PR do?

  • Have CREATE and GET on resource endpoint in express REST API

Description of Task to be completed?

Have the following endpoints working

  • CREATE api/v1/user/:articleSlug/stats
  • PATCH api/v1/user/profile/stats

How should this be manually tested?

  • It should be tested using POSTMAN

Any background context you want to provide?

  • None

What are the relevant pivotal tracker stories?

  • (#165412937)[https://www.pivotaltracker.com/story/show/165412937]

Screenshots (if appropriate)

  • None

Questions:

@luc-tuyishime luc-tuyishime requested a review from rwajon June 7, 2019 10:40
@luc-tuyishime luc-tuyishime force-pushed the feature/be-reading-stats-165412937 branch 3 times, most recently from 91ad001 to ad749b2 Compare June 7, 2019 15:08
const { tagList } = req.body;
const newArticle = await Article.create({
userId: req.user.id || 0,
slug: helpers.generator.slug(req.body.title),
title: req.body.title.trim(),
description: req.body.description.trim(),
body: req.body.body.trim(),
coverUrl: image.image.original,
// coverUrl: image.image.original,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented lines

Copy link
Contributor Author

@luc-tuyishime luc-tuyishime Jun 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already removed

const { tagList } = req.body;
const newArticle = await Article.create({
userId: req.user.id || 0,
slug: helpers.generator.slug(req.body.title),
title: req.body.title.trim(),
description: req.body.description.trim(),
body: req.body.body.trim(),
coverUrl: image.image.original,
// coverUrl: image.image.original,
coverUrl: req.body.coverUrl || 'placeholder.png',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove placeholder

Copy link
Contributor Author

@luc-tuyishime luc-tuyishime Jun 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too was already removed

@@ -1,5 +1,5 @@
import dotenv from 'dotenv';
import { User } from '../queries';
import { User, findAndCountAll, create } from '../queries';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does findAndCountAll query?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findAndCountAll return both data and total count.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count for what? it should be named appropriately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have renamed to an appropriate name.

@luc-tuyishime luc-tuyishime force-pushed the feature/be-reading-stats-165412937 branch 2 times, most recently from e1a232e to a087945 Compare June 10, 2019 13:29
@@ -1,5 +1,5 @@
import dotenv from 'dotenv';
import { User } from '../queries';
import { User, findAndCountAll, create } from '../queries';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count for what? it should be named appropriately

@luc-tuyishime luc-tuyishime force-pushed the feature/be-reading-stats-165412937 branch from a087945 to 4711a44 Compare June 10, 2019 14:33
@@ -1,5 +1,5 @@
import dotenv from 'dotenv';
import { User } from '../queries';
import { User, getAll, create } from '../queries';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be something like getAllRatings, use the object approach. Have an object ReadingStat and inside that have all the methods you want. That way you can name them the way you have it above. getAll and Create. This makes it easier to read and use. You will import the ReadingStat object and anywhere you want to use it you will invoke ReadingStat.create or ReadingStat.getAll

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@luc-tuyishime luc-tuyishime force-pushed the feature/be-reading-stats-165412937 branch 5 times, most recently from 0116e0f to 83e81b8 Compare June 11, 2019 08:07
@luc-tuyishime luc-tuyishime force-pushed the feature/be-reading-stats-165412937 branch from 83e81b8 to e98563e Compare June 11, 2019 12:05
@e-liyai e-liyai merged commit e6b053b into develop Jun 11, 2019
@e-liyai e-liyai deleted the feature/be-reading-stats-165412937 branch June 11, 2019 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants