-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(admin):admin can view statistics #80
Conversation
src/controllers/adminStatistics.ts
Outdated
@@ -0,0 +1,64 @@ | |||
import { Request, Response } from "express"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/routes/adminStatsRoute.ts
Outdated
@@ -0,0 +1,13 @@ | |||
import express from "express"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/controllers/adminStatistics.ts
Outdated
export const adminStatistics = async (req: Request, res: Response) => { | ||
try { | ||
const admin_token = req.headers.authorization?.split(" ")[1]; | ||
if (admin_token) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as we have middleware for checking if user is admin, we don't need to use these checking in controller.
just remove it and middleware will do the job.
fc9b027
to
0b3a169
Compare
const activeBuyers = allBuyers.rows.filter((item) => item.isActive); | ||
const activeSellers = allSellers.rows.filter((item) => item.isActive); | ||
const allOrders = await Order.findAndCountAll({ | ||
include: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
0b3a169
to
c3c8926
Compare
Code Climate has analyzed commit c3c8926 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 50.0% (60% is the threshold). This pull request will bring the total coverage in the repository to 96.4% (-0.8% change). View more on Code Climate. |
What does this PR do?
A admin can have some statistics of all app.
How should this be manually tested?
Clone the repo and cd into it
Checkout to feat-admin-stat and run npm install
Run npm run dev to start the application locally
login as admin and navigate to /admin/stat