feat/report #4

Merged
firmanr merged 3 commits from feat/report into development 2024-06-25 06:54:12 +00:00
12 changed files with 208 additions and 3 deletions

View File

@ -23,7 +23,8 @@
"seed:config": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js -n ./src/database/seed-ormconfig.ts config",
"seed:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js -n ./src/database/seed-ormconfig.ts seed",
"factory:config": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js -n ./src/database/seed-data-ormconfig.ts config",
"factory:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js -n ./src/database/seed-data-ormconfig.ts seed"
"factory:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js -n ./src/database/seed-data-ormconfig.ts seed",
"db:generate": "npm run orm migration:generate"
},
"dependencies": {
"@faker-js/faker": "^8.4.1",
@ -89,4 +90,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}

View File

@ -15,4 +15,7 @@ export enum TABLE_NAME {
USER_PRIVILEGE_CONFIGURATION = 'user_privilege_configurations',
VIP_CATEGORY = 'vip_categories',
VIP_CODE = 'vip_codes',
REPORT_BOOKMARK = 'report_bookmark',
EXPORT_REPORT_HISTORY = 'export_report_history',
}

View File

@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class InitTableReport1719298201894 implements MigrationInterface {
name = 'InitTableReport1719298201894';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "report_bookmark" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "group_name" character varying NOT NULL, "unique_name" character varying NOT NULL, "label" character varying NOT NULL, "applied" boolean DEFAULT false, "configuration" json, CONSTRAINT "PK_d72aa68a7ee505edf4f3e156946" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TYPE "public"."export_report_history_status_enum" AS ENUM('processing', 'done', 'failed', 'cancel')`,
);
await queryRunner.query(
`CREATE TABLE "export_report_history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "group_name" character varying NOT NULL, "unique_name" character varying NOT NULL, "label" character varying NOT NULL, "file_name" character varying NOT NULL, "file_url" character varying, "total_data" integer NOT NULL DEFAULT '0', "processing_data" integer NOT NULL DEFAULT '0', "status" "public"."export_report_history_status_enum", "last_process_offset" integer NOT NULL DEFAULT '0', "last_process_limit" integer NOT NULL DEFAULT '0', "total_resume" integer NOT NULL DEFAULT '0', "last_resume_created_at" bigint, "query_export" character varying, "canceled_at" bigint, CONSTRAINT "PK_07a632c94dca0728ad1b51ed65c" PRIMARY KEY ("id"))`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "export_report_history"`);
await queryRunner.query(
`DROP TYPE "public"."export_report_history_status_enum"`,
);
await queryRunner.query(`DROP TABLE "report_bookmark"`);
}
}

View File

@ -9,7 +9,10 @@ export const connectionSource = new DataSource({
username: process.env.DEFAULT_DB_USER,
password: process.env.DEFAULT_DB_PASS,
database: process.env.DEFAULT_DB_NAME,
entities: ['src/modules/**/**/data/models/*.ts'],
entities: [
'src/modules/**/**/data/models/*.ts',
'src/modules/reports/shared/models/*.ts',
],
migrationsTableName: 'migrations',
migrations: ['src/database/migrations/*.ts'],
synchronize: false,

View File

@ -0,0 +1,3 @@
export * from './report-config.constant';
export * from './report-group.constant';
export * from './report-status.constant';

View File

@ -0,0 +1,53 @@
export enum DATA_FORMAT {
TEXT = 'text',
TEXT_UPPERCASE = 'text_uppercase',
TEXT_LOWERCASE = 'text_lowercase',
NUMBER = 'number',
MINUS_NUMBER = 'minus_number',
DATE_EPOCH = 'date_epoch',
DATE_TIMESTAMP = 'date_timestamp',
CURRENCY = 'currency',
MINUS_CURRENCY = 'minus_currency',
STATUS = 'status',
BOOLEAN = 'boolean',
PERCENTAGE = 'percentage',
}
export enum DATA_TYPE {
DIMENSION = 'dimension',
MEASURE = 'measure',
}
export enum FILTER_TYPE {
TEXT_EQUAL = 'text_equals',
TEXT_NOT_EQUAL = 'text_notEquals',
TEXT_CONTAINS = 'text_contains',
TEXT_MULTIPLE_CONTAINS = 'text_multiple_contains',
TEXT_MULTIPLE_REGEXP_CONTAINS = 'text_multiple_regexp_contains',
TEXT_NOT_CONTAINS = 'text_notContains',
TEXT_START_WITH = 'text_startWith',
TEXT_END_WITH = 'text_endWith',
TEXT_IN_MEMBER = 'text_inMemberText',
TEXT_IN_RANGE = 'text_inTextRange',
DATE_IN_RANGE_EPOCH = 'text_inDateRange_epoch',
DATE_IN_RANGE_TIMESTAMP = 'text_inDateRange_timestamp',
NUMBER_EQUAL = 'number_equals',
NUMBER_NOT_EQUAL = 'number_notEqual',
NUMBER_GREATER_THAN = 'number_greaterThan',
NUMBER_GREATER_THAN_OR_EQUAL = 'number_greaterThanOrEqual',
NUMBER_LESS_THAN = 'number_lessThan',
NUMBER_LESS_THAN_OR_EQUAL = 'number_lessThanOrEqual',
NUMBER_IN_RANGE = 'number_inRange',
}
export enum FILTER_FIELD_TYPE {
select = 'select',
input_text = 'input_text',
input_number = 'input_number',
input_tag = 'input_tag',
date_picker = 'date_picker',
date_range_picker = 'date_range_picker',
month_range_picker = 'month_range_picker',
}

View File

@ -0,0 +1,5 @@
export enum REPORT_GROUP {
// PATTERN => MODULE__MENU__SUB_MENU
// EXAMPLE:
contact__reports = 'contact__reports',
}

View File

@ -0,0 +1,6 @@
export enum REPORT_HISTORY_STATUS {
PROCESSING = 'processing',
DONE = 'done',
FAILED = 'failed',
CANCEL = 'cancel',
}

View File

@ -0,0 +1,19 @@
import { BaseEntity } from 'src/core/modules/domain/entities/base.entity';
import { REPORT_HISTORY_STATUS } from '../constant';
export interface ExportReportHistoryEntity extends BaseEntity {
group_name: string;
unique_name: string;
label: string;
file_name: string;
total_data: number;
processing_data: number;
file_url?: string;
status?: REPORT_HISTORY_STATUS;
last_process_offset?: number;
last_process_limit?: number;
total_resume?: number;
last_resume_created_at?: number;
query_export?: string;
canceled_at?: number;
}

View File

@ -0,0 +1,9 @@
import { BaseEntity } from 'src/core/modules/domain/entities/base.entity';
export interface ReportBookmarkEntity extends BaseEntity {
group_name: string;
unique_name: string;
label: string;
applied?: boolean;
configuration?: any;
}

View File

@ -0,0 +1,53 @@
import { BaseModel } from 'src/core/modules/data/model/base.model';
import { Entity, Column } from 'typeorm';
import { REPORT_HISTORY_STATUS } from '../constant';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ExportReportHistoryEntity } from '../entities/export-report-history.entity';
@Entity(TABLE_NAME.EXPORT_REPORT_HISTORY)
export class ExportReportHistoryModel
extends BaseModel<ExportReportHistoryEntity>
implements ExportReportHistoryEntity
{
@Column('varchar')
group_name: string;
@Column('varchar')
unique_name: string;
@Column('varchar')
label: string;
@Column('varchar')
file_name: string;
@Column('varchar', { nullable: true })
file_url: string;
@Column('int', { default: 0 })
total_data: number;
@Column('int', { default: 0 })
processing_data: number;
@Column('enum', { nullable: true, enum: REPORT_HISTORY_STATUS })
status: REPORT_HISTORY_STATUS;
@Column('int', { default: 0 })
last_process_offset: number;
@Column('int', { default: 0 })
last_process_limit: number;
@Column('int', { default: 0 })
total_resume: number;
@Column('bigint', { nullable: true })
last_resume_created_at: number;
@Column('varchar', { nullable: true })
query_export: string;
@Column({ type: 'bigint', nullable: true })
canceled_at: number;
}

View File

@ -0,0 +1,25 @@
import { BaseModel } from 'src/core/modules/data/model/base.model';
import { Entity, Column } from 'typeorm';
import { ReportBookmarkEntity } from '../entities/report-bookmark.entity';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
@Entity(TABLE_NAME.REPORT_BOOKMARK)
export class ReportBookmarkModel
extends BaseModel<ReportBookmarkEntity>
implements ReportBookmarkEntity
{
@Column('varchar')
group_name: string;
@Column('varchar')
unique_name: string;
@Column('varchar')
label: string;
@Column('bool', { nullable: true, default: false })
applied: boolean;
@Column('json', { nullable: true })
configuration: any;
}