chore: approve invoice, reports for admin dashboard
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Controller, Get } from "@nestjs/common";
|
||||
|
||||
import { DashboardService } from "./providers/dashboard.service";
|
||||
|
||||
@Controller("dashboards")
|
||||
export class DashboardController {
|
||||
constructor(private readonly dashboardService: DashboardService) {}
|
||||
|
||||
@Get("reports")
|
||||
async reports() {
|
||||
return this.dashboardService.reports();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
|
||||
import { DashboardController } from "./dashboard.controller";
|
||||
import { AdsModule } from "../ads/ads.module";
|
||||
import { DanakServicesModule } from "../danak-services/danak-services.module";
|
||||
import { InvoicesModule } from "../invoices/invoices.module";
|
||||
import { TicketsModule } from "../tickets/tickets.module";
|
||||
import { UsersModule } from "../users/users.module";
|
||||
import { DashboardService } from "./providers/dashboard.service";
|
||||
import { SubscriptionsModule } from "../subscriptions/subscriptions.module";
|
||||
|
||||
@Module({
|
||||
imports: [InvoicesModule, TicketsModule, UsersModule, AdsModule, DanakServicesModule, SubscriptionsModule],
|
||||
providers: [DashboardService],
|
||||
controllers: [DashboardController],
|
||||
})
|
||||
export class DashboardModule {}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { AdsService } from "../../ads/providers/ads.service";
|
||||
import { DanakServicesService } from "../../danak-services/providers/danak-services.service";
|
||||
import { InvoicesService } from "../../invoices/providers/invoices.service";
|
||||
import { SubscriptionsService } from "../../subscriptions/providers/subscriptions.service";
|
||||
import { TicketsService } from "../../tickets/providers/tickets.service";
|
||||
import { UsersService } from "../../users/providers/users.service";
|
||||
|
||||
@Injectable()
|
||||
export class DashboardService {
|
||||
constructor(
|
||||
private readonly danakServicesService: DanakServicesService,
|
||||
private readonly usersService: UsersService,
|
||||
private readonly invoicesService: InvoicesService,
|
||||
private readonly ticketsService: TicketsService,
|
||||
private readonly adsService: AdsService,
|
||||
private readonly subscriptionsService: SubscriptionsService,
|
||||
) {}
|
||||
|
||||
//************************************ */
|
||||
|
||||
async reports() {
|
||||
const danakServicesCount = await this.getDanakServicesCount();
|
||||
const customersCount = await this.getCustomersCount();
|
||||
const invoicesCount = await this.getInvoicesCount();
|
||||
const unreadTickets = await this.unreadTickets();
|
||||
const adsCount = await this.getAdsCount();
|
||||
const planRevenueAverage = await this.getPlanRevenueAverage();
|
||||
const plansSalesCount = await this.getPlansSalesCount();
|
||||
const subscriptionGrowthRate = await this.getSubscriptionGrowthRate();
|
||||
const plansSalesCountByMonthsInYear = await this.getPlansSalesCountByMonthsInYear();
|
||||
const plansSalesCountByDaysInMonth = await this.getPlansSalesCountByDaysInMonth();
|
||||
const plansSalesCountByDaysInWeek = await this.getPlansSalesCountByDaysInWeek();
|
||||
return {
|
||||
danakServicesCount,
|
||||
customersCount,
|
||||
invoicesCount,
|
||||
unreadTickets,
|
||||
adsCount,
|
||||
planRevenueAverage,
|
||||
plansSalesCount,
|
||||
subscriptionGrowthRate,
|
||||
plansSalesCountByMonthsInYear,
|
||||
plansSalesCountByDaysInMonth,
|
||||
plansSalesCountByDaysInWeek,
|
||||
};
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getDanakServicesCount() {
|
||||
const danakServicesCount = await this.danakServicesService.getServicesCount();
|
||||
return danakServicesCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getCustomersCount() {
|
||||
const customersCount = await this.usersService.getCustomersCount();
|
||||
return customersCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getInvoicesCount() {
|
||||
const invoicesCount = await this.invoicesService.getInvoicesCount();
|
||||
return invoicesCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async unreadTickets() {
|
||||
const unreadTickets = await this.ticketsService.getUnreadTickets();
|
||||
return unreadTickets;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getAdsCount() {
|
||||
const adsCount = await this.adsService.getAdsCount();
|
||||
return adsCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getPlanRevenueAverage() {
|
||||
const planRevenueCount = await this.subscriptionsService.getPlanRevenueAverage();
|
||||
return planRevenueCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getPlansSalesCount() {
|
||||
const plansSalesCount = await this.subscriptionsService.getPlansSalesCount();
|
||||
return plansSalesCount;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getSubscriptionGrowthRate() {
|
||||
const subscriptionGrowthRate = await this.subscriptionsService.getSubscriptionGrowthRate();
|
||||
return subscriptionGrowthRate;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getPlansSalesCountByMonthsInYear() {
|
||||
const plansSalesCountByMonthsInYear = await this.subscriptionsService.getPlansSalesCountByMonthsInYear();
|
||||
return plansSalesCountByMonthsInYear;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getPlansSalesCountByDaysInMonth() {
|
||||
const plansSalesCountByDaysInMonth = await this.subscriptionsService.getPlansSalesCountByDaysInMonth();
|
||||
return plansSalesCountByDaysInMonth;
|
||||
}
|
||||
|
||||
//************************************ */
|
||||
|
||||
private async getPlansSalesCountByDaysInWeek() {
|
||||
const plansSalesCountByDaysInWeek = await this.subscriptionsService.getPlansSalesCountByDaysInWeek();
|
||||
return plansSalesCountByDaysInWeek;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user