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

Get /stats #28

Closed
3 tasks done
Mu7ammadAbed opened this issue Mar 26, 2020 · 0 comments
Closed
3 tasks done

Get /stats #28

Mu7ammadAbed opened this issue Mar 26, 2020 · 0 comments
Assignees

Comments

@Mu7ammadAbed
Copy link
Member

Mu7ammadAbed commented Mar 26, 2020

relates #5

Route: GET api/v1/stats

Acceptance Criteria

  • DB query
  • Response
  • Testing

DB query

We will use #14 , #26 , #16 and #17 query functions to get the length of each table to use in the stats board

// This is from a previous example you can use it as a reference

router.get('/stats', (req, res) => {
  getAllData()
    .then(({ rows }) => console.log(rows.length)) // this will log the length
    .catch((err) => next(err));
});

OR:
We can use the count function like this to count the number of rows per table

SELECT COUNT(id) 
 FROM cohort 
 UNION ALL 
 SELECT COUNT(id) 
 FROM project 
 UNION ALL 
 SELECT COUNT(id) 
 FROM student

Response

  • Success
{ StatusCode: 200,
data: [ { count: '11' }, { count: '22' }, { count: '154' }  ]
}
  • Failed
{statusCode:400, message:"Bad Request"}

Testing

to be a successful test

  • status === 200
  • typeof(data) === "object"
@rehabas rehabas added in progress and removed To-Do labels Apr 3, 2020
rehabas added a commit that referenced this issue Apr 3, 2020
rehabas added a commit that referenced this issue Apr 3, 2020
@rehabas rehabas added Awaiting Review This PR is ready and waiting for review and removed in progress labels Apr 4, 2020
rehabas added a commit that referenced this issue Apr 4, 2020
rehabas added a commit that referenced this issue Apr 4, 2020
relates #28
@rehabas rehabas mentioned this issue Apr 4, 2020
@ranasobeid95 ranasobeid95 added Done and removed Awaiting Review This PR is ready and waiting for review labels Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants