Compare commits

..

No commits in common. "2f03f18d519ef3abd7fd7b4ba531eb0fd0e97a76" and "c9b55c3d914045fdfcb34c5c63a55b421a6b117f" have entirely different histories.

2 changed files with 5 additions and 49 deletions

View File

@ -4,12 +4,11 @@ import { ReportService } from './report.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ExportReportHistoryModel } from '../shared/models/export-report-history.model';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
import { ReportBookmarkModel } from '../shared/models/report-bookmark.model';
@Module({
imports: [
TypeOrmModule.forFeature(
[ExportReportHistoryModel, ReportBookmarkModel],
[ExportReportHistoryModel],
CONNECTION_NAME.DEFAULT,
),
],

View File

@ -3,14 +3,13 @@ import { BaseReportService } from '../shared/services/base-report.service';
import { GetReportConfigDto } from '../shared/dto/report-config.get.dto';
import { GetReportDataDto } from '../shared/dto/report-data.get.dto';
import { ReportConfigs } from '../shared/configs';
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
import { InjectDataSource } from '@nestjs/typeorm';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
import { DataSource, Repository } from 'typeorm';
import { DataSource } from 'typeorm';
import { ReportConfigEntity } from '../shared/entities/report-config.entity';
import { ReportQueryBuilder } from '../shared/helpers';
import { DATA_FORMAT, REPORT_BOOKMARK_TYPE } from '../shared/constant';
import { DATA_FORMAT } from '../shared/constant';
import { roundingCurrency } from '../shared/helpers';
import { ReportBookmarkModel } from '../shared/models/report-bookmark.model';
@Injectable({ scope: Scope.REQUEST })
export class ReportService extends BaseReportService {
@ -19,9 +18,6 @@ export class ReportService extends BaseReportService {
constructor(
@InjectDataSource(CONNECTION_NAME.DEFAULT)
private dataSource: DataSource,
@InjectRepository(ReportBookmarkModel, CONNECTION_NAME.DEFAULT)
private bookmarkRepo: Repository<ReportBookmarkModel>,
) {
super();
}
@ -39,47 +35,8 @@ export class ReportService extends BaseReportService {
unique_names.includes(item.unique_name),
);
}
const groups = Array.from(new Set(configs?.map((item) => item.group_name)));
const names = Array.from(new Set(configs?.map((item) => item.unique_name)));
const modelName = ReportBookmarkModel.name;
const creator_id = this.getUser().id;
const bookmarkConfigs = await this.bookmarkRepo
.createQueryBuilder(modelName)
.where((query) => {
if (names.length > 0) {
query.andWhere(`group_name IN (:...groups)`, { groups });
}
if (groups.length > 0) {
query.andWhere(`unique_name IN (:...names)`, { names });
}
query.andWhere(`creator_id = :creator_id`, { creator_id });
query.andWhere(`applied = :applied`, { applied: true });
})
.getMany();
return configs.map((item) => {
const active_filter = bookmarkConfigs.find(
(conf) =>
conf.group_name === item.group_name &&
conf.unique_name === item.unique_name &&
conf.type === REPORT_BOOKMARK_TYPE.FILTER_TABLE,
);
const active_table_config = bookmarkConfigs.find(
(conf) =>
conf.group_name === item.group_name &&
conf.unique_name === item.unique_name &&
conf.type === REPORT_BOOKMARK_TYPE.TABLE_CONFIG,
);
return {
...item,
active_filter: active_filter ?? {},
active_table_config: active_table_config ?? {},
};
});
return configs;
}
getReportConfigByUniqueName(group_name, unique_name): ReportConfigEntity {