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

feat(admin):admin can view statistics #80

Merged
merged 1 commit into from
Jul 25, 2024
Merged

Conversation

Tuyisenge2
Copy link
Collaborator

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

@@ -0,0 +1,64 @@
import { Request, Response } from "express";
Copy link

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'

@@ -0,0 +1,13 @@
import express from "express";
Copy link

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'

export const adminStatistics = async (req: Request, res: Response) => {
try {
const admin_token = req.headers.authorization?.split(" ")[1];
if (admin_token) {
Copy link
Collaborator

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.

@Tuyisenge2 Tuyisenge2 added the enhancement New feature or request label Jul 25, 2024
const activeBuyers = allBuyers.rows.filter((item) => item.isActive);
const activeSellers = allSellers.rows.filter((item) => item.isActive);
const allOrders = await Order.findAndCountAll({
include: {
Copy link

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.

@Tuyisenge2 Tuyisenge2 removed the enhancement New feature or request label Jul 25, 2024
Copy link

codeclimate bot commented Jul 25, 2024

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.

@leandreAlly leandreAlly merged commit 1d98af8 into develop Jul 25, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants