|
|
@@ -44,15 +44,15 @@ const MAX_SIZE = 200;
|
|
|
export class StatsReportingService {
|
|
|
constructor(private readonly prisma: PrismaMongoService) {}
|
|
|
|
|
|
- async getAdsHourly(query: AdsStatsQueryDto): Promise<any> {
|
|
|
- assertRange(query.fromSec, query.toSec);
|
|
|
+ async getAdsHourly(dto: AdsStatsQueryDto): Promise<any> {
|
|
|
+ assertRange(dto.fromSec, dto.toSec);
|
|
|
const { page, size, skip, take } = this.normalizePagination({
|
|
|
- page: query.page,
|
|
|
- size: query.size,
|
|
|
+ page: dto.page,
|
|
|
+ size: dto.size,
|
|
|
});
|
|
|
|
|
|
- const fromAligned = alignHourStart(query.fromSec);
|
|
|
- const toAligned = alignHourStart(query.toSec);
|
|
|
+ const fromAligned = alignHourStart(dto.fromSec);
|
|
|
+ const toAligned = alignHourStart(dto.toSec);
|
|
|
|
|
|
const where: Prisma.AdsHourlyStatsWhereInput = {
|
|
|
hourStartAt: {
|
|
|
@@ -61,8 +61,8 @@ export class StatsReportingService {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- if (query.adsId) {
|
|
|
- where.adsId = query.adsId;
|
|
|
+ if (dto.adsId) {
|
|
|
+ where.adsId = dto.adsId;
|
|
|
}
|
|
|
|
|
|
const [items, total] = await Promise.all([
|
|
|
@@ -78,15 +78,15 @@ export class StatsReportingService {
|
|
|
return { page, size, total, items };
|
|
|
}
|
|
|
|
|
|
- async getAdsDaily(query: AdsStatsQueryDto): Promise<any> {
|
|
|
- assertRange(query.fromSec, query.toSec);
|
|
|
+ async getAdsDaily(dto: AdsStatsQueryDto): Promise<any> {
|
|
|
+ assertRange(dto.fromSec, dto.toSec);
|
|
|
const { page, size, skip, take } = this.normalizePagination({
|
|
|
- page: query.page,
|
|
|
- size: query.size,
|
|
|
+ page: dto.page,
|
|
|
+ size: dto.size,
|
|
|
});
|
|
|
|
|
|
- const fromAligned = alignDayStart(query.fromSec);
|
|
|
- const toAligned = alignDayStart(query.toSec);
|
|
|
+ const fromAligned = alignDayStart(dto.fromSec);
|
|
|
+ const toAligned = alignDayStart(dto.toSec);
|
|
|
|
|
|
const where: Prisma.AdsDailyStatsWhereInput = {
|
|
|
dayStartAt: {
|
|
|
@@ -95,8 +95,8 @@ export class StatsReportingService {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- if (query.adsId) {
|
|
|
- where.adsId = query.adsId;
|
|
|
+ if (dto.adsId) {
|
|
|
+ where.adsId = dto.adsId;
|
|
|
}
|
|
|
|
|
|
const [items, total] = await Promise.all([
|
|
|
@@ -112,15 +112,15 @@ export class StatsReportingService {
|
|
|
return { page, size, total, items };
|
|
|
}
|
|
|
|
|
|
- async getChannelHourlyUsers(query: ChannelStatsQueryDto): Promise<any> {
|
|
|
- assertRange(query.fromSec, query.toSec);
|
|
|
+ async getChannelHourlyUsers(dto: ChannelStatsQueryDto): Promise<any> {
|
|
|
+ assertRange(dto.fromSec, dto.toSec);
|
|
|
const { page, size, skip, take } = this.normalizePagination({
|
|
|
- page: query.page,
|
|
|
- size: query.size,
|
|
|
+ page: dto.page,
|
|
|
+ size: dto.size,
|
|
|
});
|
|
|
|
|
|
- const fromAligned = alignHourStart(query.fromSec);
|
|
|
- const toAligned = alignHourStart(query.toSec);
|
|
|
+ const fromAligned = alignHourStart(dto.fromSec);
|
|
|
+ const toAligned = alignHourStart(dto.toSec);
|
|
|
|
|
|
const where: Prisma.ChannelHourlyUserStatsWhereInput = {
|
|
|
hourStartAt: {
|
|
|
@@ -129,8 +129,8 @@ export class StatsReportingService {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- if (query.channelId) {
|
|
|
- where.channelId = query.channelId;
|
|
|
+ if (dto.channelId) {
|
|
|
+ where.channelId = dto.channelId;
|
|
|
}
|
|
|
|
|
|
const [items, total] = await Promise.all([
|
|
|
@@ -146,15 +146,15 @@ export class StatsReportingService {
|
|
|
return { page, size, total, items };
|
|
|
}
|
|
|
|
|
|
- async getChannelDailyUsers(query: ChannelStatsQueryDto): Promise<any> {
|
|
|
- assertRange(query.fromSec, query.toSec);
|
|
|
+ async getChannelDailyUsers(dto: ChannelStatsQueryDto): Promise<any> {
|
|
|
+ assertRange(dto.fromSec, dto.toSec);
|
|
|
const { page, size, skip, take } = this.normalizePagination({
|
|
|
- page: query.page,
|
|
|
- size: query.size,
|
|
|
+ page: dto.page,
|
|
|
+ size: dto.size,
|
|
|
});
|
|
|
|
|
|
- const fromAligned = alignDayStart(query.fromSec);
|
|
|
- const toAligned = alignDayStart(query.toSec);
|
|
|
+ const fromAligned = alignDayStart(dto.fromSec);
|
|
|
+ const toAligned = alignDayStart(dto.toSec);
|
|
|
|
|
|
const where: Prisma.ChannelDailyUserStatsWhereInput = {
|
|
|
dayStartAt: {
|
|
|
@@ -163,8 +163,8 @@ export class StatsReportingService {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- if (query.channelId) {
|
|
|
- where.channelId = query.channelId;
|
|
|
+ if (dto.channelId) {
|
|
|
+ where.channelId = dto.channelId;
|
|
|
}
|
|
|
|
|
|
const [items, total] = await Promise.all([
|