From a7feeb34cf6ee79242f4bbb7fe6ac967a9334120 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Sun, 24 Nov 2024 23:36:24 +0900 Subject: [PATCH 01/11] =?UTF-8?q?setting:=20cache-manager=EC=99=80=20redis?= =?UTF-8?q?=EC=97=90=20=ED=95=84=EC=9A=94=ED=95=9C=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/package-lock.json | 177 +++++++++++++++++++++++ backend/console-server/package.json | 3 + 2 files changed, 180 insertions(+) diff --git a/backend/console-server/package-lock.json b/backend/console-server/package-lock.json index d3412ed2..45f9f509 100644 --- a/backend/console-server/package-lock.json +++ b/backend/console-server/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@clickhouse/client": "^1.8.0", "@nestjs-modules/mailer": "^2.0.2", + "@nestjs/cache-manager": "^2.3.0", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.3.0", "@nestjs/core": "^10.0.0", @@ -18,6 +19,8 @@ "@nestjs/platform-express": "^10.0.0", "@nestjs/swagger": "^8.0.5", "@nestjs/typeorm": "^10.0.2", + "cache-manager": "^5.7.6", + "cache-manager-redis-yet": "^5.1.5", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "handlebars": "^4.7.8", @@ -1959,6 +1962,18 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/@nestjs/cache-manager": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@nestjs/cache-manager/-/cache-manager-2.3.0.tgz", + "integrity": "sha512-pxeBp9w/s99HaW2+pezM1P3fLiWmUEnTUoUMLa9UYViCtjj0E0A19W/vaT5JFACCzFIeNrwH4/16jkpAhQ25Vw==", + "license": "MIT", + "peerDependencies": { + "@nestjs/common": "^9.0.0 || ^10.0.0", + "@nestjs/core": "^9.0.0 || ^10.0.0", + "cache-manager": "<=5", + "rxjs": "^7.0.0" + } + }, "node_modules/@nestjs/cli": { "version": "10.4.7", "resolved": "https://registry.npmjs.org/@nestjs/cli/-/cli-10.4.7.tgz", @@ -2354,6 +2369,71 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "license": "MIT", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/client": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz", + "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==", + "license": "MIT", + "dependencies": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@redis/client/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "license": "ISC" + }, + "node_modules/@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "license": "MIT", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/json": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz", + "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==", + "license": "MIT", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/search": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz", + "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==", + "license": "MIT", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/time-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz", + "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==", + "license": "MIT", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, "node_modules/@scarf/scarf": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz", @@ -4033,6 +4113,47 @@ "license": "ISC", "optional": true }, + "node_modules/cache-manager": { + "version": "5.7.6", + "resolved": "https://registry.npmjs.org/cache-manager/-/cache-manager-5.7.6.tgz", + "integrity": "sha512-wBxnBHjDxF1RXpHCBD6HGvKER003Ts7IIm0CHpggliHzN1RZditb7rXoduE1rplc2DEFYKxhLKgFuchXMJje9w==", + "license": "MIT", + "dependencies": { + "eventemitter3": "^5.0.1", + "lodash.clonedeep": "^4.5.0", + "lru-cache": "^10.2.2", + "promise-coalesce": "^1.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/cache-manager-redis-yet": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/cache-manager-redis-yet/-/cache-manager-redis-yet-5.1.5.tgz", + "integrity": "sha512-NYDxrWBoLXxxVPw4JuBriJW0f45+BVOAsgLiozRo4GoJQyoKPbueQWYStWqmO73/AeHJeWrV7Hzvk6vhCGHlqA==", + "deprecated": "With cache-manager v6 we now are using Keyv", + "license": "MIT", + "dependencies": { + "@redis/bloom": "^1.2.0", + "@redis/client": "^1.6.0", + "@redis/graph": "^1.1.1", + "@redis/json": "^1.0.7", + "@redis/search": "^1.2.0", + "@redis/time-series": "^1.1.0", + "cache-manager": "^5.7.6", + "redis": "^4.7.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/cache-manager/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -4500,6 +4621,15 @@ "node": ">=0.8" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -5736,6 +5866,12 @@ "node": ">= 0.6" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -6395,6 +6531,15 @@ "is-property": "^1.0.2" } }, + "node_modules/generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -8507,6 +8652,12 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "license": "MIT" }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", + "license": "MIT" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -10658,6 +10809,15 @@ "asap": "~2.0.3" } }, + "node_modules/promise-coalesce": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/promise-coalesce/-/promise-coalesce-1.1.2.tgz", + "integrity": "sha512-zLaJ9b8hnC564fnJH6NFSOGZYYdzrAJn2JUUIwzoQb32fG2QAakpDNM+CZo1km6keXkRXRM+hml1BFAPVnPkxg==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=16" + } + }, "node_modules/promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -11044,6 +11204,23 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/redis": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz", + "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==", + "license": "MIT", + "workspaces": [ + "./packages/*" + ], + "dependencies": { + "@redis/bloom": "1.2.0", + "@redis/client": "1.6.0", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.7", + "@redis/search": "1.2.0", + "@redis/time-series": "1.1.0" + } + }, "node_modules/reflect-metadata": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", diff --git a/backend/console-server/package.json b/backend/console-server/package.json index 5b9979cd..dccdbaf4 100644 --- a/backend/console-server/package.json +++ b/backend/console-server/package.json @@ -23,6 +23,7 @@ "dependencies": { "@clickhouse/client": "^1.8.0", "@nestjs-modules/mailer": "^2.0.2", + "@nestjs/cache-manager": "^2.3.0", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.3.0", "@nestjs/core": "^10.0.0", @@ -30,6 +31,8 @@ "@nestjs/platform-express": "^10.0.0", "@nestjs/swagger": "^8.0.5", "@nestjs/typeorm": "^10.0.2", + "cache-manager": "^5.7.6", + "cache-manager-redis-yet": "^5.1.5", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "handlebars": "^4.7.8", From 08562dce262330000f9864714c5afc4cfc84506e Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Sun, 24 Nov 2024 23:37:11 +0900 Subject: [PATCH 02/11] =?UTF-8?q?setting:=20redis=20config=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../console-server/src/config/redis.config.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 backend/console-server/src/config/redis.config.ts diff --git a/backend/console-server/src/config/redis.config.ts b/backend/console-server/src/config/redis.config.ts new file mode 100644 index 00000000..dd93f8e7 --- /dev/null +++ b/backend/console-server/src/config/redis.config.ts @@ -0,0 +1,16 @@ +import { registerAs } from '@nestjs/config'; +import { redisStore } from 'cache-manager-redis-yet'; + +export default registerAs('redisConfig', async () => { + const store = await redisStore({ + socket: { + host: process.env.REDIS_HOST || 'localhost', + port: Number(process.env.REDIS_PORT) || 6379, + }, + }); + + return { + store: store, + ttl: 3 * 60 * 1000, + }; +}); From 947fecc54f91f699650e64535a15018fa45e9331 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Sun, 24 Nov 2024 23:38:44 +0900 Subject: [PATCH 03/11] =?UTF-8?q?setting:=20AppModule=EC=97=90=EC=84=9C=20?= =?UTF-8?q?global=EB=A1=9C=20CacheModule=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/src/app.module.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/console-server/src/app.module.ts b/backend/console-server/src/app.module.ts index 6d2fcc98..b873b7fb 100644 --- a/backend/console-server/src/app.module.ts +++ b/backend/console-server/src/app.module.ts @@ -10,15 +10,21 @@ import mailerConfig from './config/mailer.config'; import { ClickhouseModule } from './clickhouse/clickhouse.module'; import { LogModule } from './log/log.module'; import clickhouseConfig from './config/clickhouse.config'; +import { CacheModule } from '@nestjs/cache-manager'; +import redisConfig from './config/redis.config'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: [mailerConfig, clickhouseConfig] }), TypeOrmModule.forRootAsync(typeOrmConfig.asProvider()), - ProjectModule, ClickhouseModule, - LogModule, + CacheModule.registerAsync({ + isGlobal: true, + ...redisConfig.asProvider(), + }), MailModule, + ProjectModule, + LogModule, ], controllers: [AppController], providers: [AppService], From 2cae04d1fe09b5c97a8b412bc2d2bf4f816d0c7a Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Sun, 24 Nov 2024 23:42:28 +0900 Subject: [PATCH 04/11] =?UTF-8?q?setting:=20docker-compose=EC=97=90=20redi?= =?UTF-8?q?s=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 3cfea514..b35a1389 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -1,5 +1,15 @@ version: '3.8' services: + + redis: + image: redis:latest + container_name: app-redis + restart: always + ports: + - "6379:6379" + networks: + - app-network + nginx: image: nginx:latest ports: From d35923e1785163880f553820068b5dd3e60fe32c Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 00:02:34 +0900 Subject: [PATCH 05/11] =?UTF-8?q?style:=20analytics=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD=20-=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=84=EB=B6=80=20pass=20=ED=99=95=EC=9D=B8=20Te?= =?UTF-8?q?st=20Suites:=2017=20passed,=2017=20total=20Tests:=20=20=20=20?= =?UTF-8?q?=20=20=20110=20passed,=20110=20total=20Snapshots:=20=20=200=20t?= =?UTF-8?q?otal=20Time:=20=20=20=20=20=20=20=204.954=20s,=20estimated=205?= =?UTF-8?q?=20s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analytics.controller.spec.ts} | 21 ++++++++++--------- .../analytics.controller.ts} | 8 +++---- .../analytics.module.ts} | 12 +++++------ .../analytics.repository.spec.ts} | 10 ++++----- .../analytics.repository.ts} | 2 +- .../analytics.service.spec.ts} | 14 ++++++------- .../analytics.service.ts} | 6 +++--- .../dto/get-project-dau-response.dto.ts | 0 .../dto/get-project-dau.dto.ts | 0 .../metric/dau.metric.ts | 0 backend/console-server/src/log/log.module.ts | 4 ++-- 11 files changed, 39 insertions(+), 38 deletions(-) rename backend/console-server/src/log/{analytic/analytic.controller.spec.ts => analytics/analytics.controller.spec.ts} (76%) rename backend/console-server/src/log/{analytic/analytic.controller.ts => analytics/analytics.controller.ts} (81%) rename backend/console-server/src/log/{analytic/analytic.module.ts => analytics/analytics.module.ts} (53%) rename backend/console-server/src/log/{analytic/analytic.repository.spec.ts => analytics/analytics.repository.spec.ts} (92%) rename backend/console-server/src/log/{analytic/analytic.repository.ts => analytics/analytics.repository.ts} (95%) rename backend/console-server/src/log/{analytic/analytic.service.spec.ts => analytics/analytics.service.spec.ts} (93%) rename backend/console-server/src/log/{analytic/analytic.service.ts => analytics/analytics.service.ts} (87%) rename backend/console-server/src/log/{analytic => analytics}/dto/get-project-dau-response.dto.ts (100%) rename backend/console-server/src/log/{analytic => analytics}/dto/get-project-dau.dto.ts (100%) rename backend/console-server/src/log/{analytic => analytics}/metric/dau.metric.ts (100%) diff --git a/backend/console-server/src/log/analytic/analytic.controller.spec.ts b/backend/console-server/src/log/analytics/analytics.controller.spec.ts similarity index 76% rename from backend/console-server/src/log/analytic/analytic.controller.spec.ts rename to backend/console-server/src/log/analytics/analytics.controller.spec.ts index 877efa24..577ab274 100644 --- a/backend/console-server/src/log/analytic/analytic.controller.spec.ts +++ b/backend/console-server/src/log/analytics/analytics.controller.spec.ts @@ -1,10 +1,11 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AnalyticService } from './analytic.service'; -import { AnalyticController } from './analytic.controller'; +import type { TestingModule } from '@nestjs/testing'; +import { Test } from '@nestjs/testing'; +import { AnalyticsService } from './analytics.service'; +import { AnalyticsController } from './analytics.controller'; -describe('AnalyticController 테스트', () => { - let controller: AnalyticController; - let service: AnalyticService; +describe('AnalyticsController 테스트', () => { + let controller: AnalyticsController; + let service: AnalyticsService; const mockLogService = { getProjectDAU: jest.fn(), @@ -12,17 +13,17 @@ describe('AnalyticController 테스트', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - controllers: [AnalyticController], + controllers: [AnalyticsController], providers: [ { - provide: AnalyticService, + provide: AnalyticsService, useValue: mockLogService, }, ], }).compile(); - controller = module.get(AnalyticController); - service = module.get(AnalyticService); + controller = module.get(AnalyticsController); + service = module.get(AnalyticsService); jest.clearAllMocks(); }); diff --git a/backend/console-server/src/log/analytic/analytic.controller.ts b/backend/console-server/src/log/analytics/analytics.controller.ts similarity index 81% rename from backend/console-server/src/log/analytic/analytic.controller.ts rename to backend/console-server/src/log/analytics/analytics.controller.ts index 5f0faa9e..b2087cf7 100644 --- a/backend/console-server/src/log/analytic/analytic.controller.ts +++ b/backend/console-server/src/log/analytics/analytics.controller.ts @@ -2,11 +2,11 @@ import { Controller, Get, HttpCode, HttpStatus, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse } from '@nestjs/swagger'; import { GetProjectDauResponseDto } from './dto/get-project-dau-response.dto'; import { GetProjectDAU } from './dto/get-project-dau.dto'; -import { AnalyticService } from './analytic.service'; +import { AnalyticsService } from './analytics.service'; -@Controller('analytic') -export class AnalyticController { - constructor(private readonly analyticService: AnalyticService) {} +@Controller('analytics') +export class AnalyticsController { + constructor(private readonly analyticService: AnalyticsService) {} @Get('/dau') @HttpCode(HttpStatus.OK) diff --git a/backend/console-server/src/log/analytic/analytic.module.ts b/backend/console-server/src/log/analytics/analytics.module.ts similarity index 53% rename from backend/console-server/src/log/analytic/analytic.module.ts rename to backend/console-server/src/log/analytics/analytics.module.ts index 3b0ca7d2..d4f55c9e 100644 --- a/backend/console-server/src/log/analytic/analytic.module.ts +++ b/backend/console-server/src/log/analytics/analytics.module.ts @@ -3,13 +3,13 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { Project } from '../../project/entities/project.entity'; import { ClickhouseModule } from '../../clickhouse/clickhouse.module'; import { Clickhouse } from '../../clickhouse/clickhouse'; -import { AnalyticController } from './analytic.controller'; -import { AnalyticService } from './analytic.service'; -import { AnalyticRepository } from './analytic.repository'; +import { AnalyticsController } from './analytics.controller'; +import { AnalyticsService } from './analytics.service'; +import { AnalyticsRepository } from './analytics.repository'; @Module({ imports: [TypeOrmModule.forFeature([Project]), ClickhouseModule], - providers: [AnalyticService, AnalyticRepository, Clickhouse], - controllers: [AnalyticController], + providers: [AnalyticsService, AnalyticsRepository, Clickhouse], + controllers: [AnalyticsController], }) -export class AnalyticModule {} +export class AnalyticsModule {} diff --git a/backend/console-server/src/log/analytic/analytic.repository.spec.ts b/backend/console-server/src/log/analytics/analytics.repository.spec.ts similarity index 92% rename from backend/console-server/src/log/analytic/analytic.repository.spec.ts rename to backend/console-server/src/log/analytics/analytics.repository.spec.ts index 0a120d70..987683e7 100644 --- a/backend/console-server/src/log/analytic/analytic.repository.spec.ts +++ b/backend/console-server/src/log/analytics/analytics.repository.spec.ts @@ -1,10 +1,10 @@ import { Clickhouse } from '../../clickhouse/clickhouse'; import type { TestingModule } from '@nestjs/testing'; import { Test } from '@nestjs/testing'; -import { AnalyticRepository } from './analytic.repository'; +import { AnalyticsRepository } from './analytics.repository'; -describe('AnalyticRepository 테스트', () => { - let repository: AnalyticRepository; +describe('AnalyticsRepository 테스트', () => { + let repository: AnalyticsRepository; let clickhouse: Clickhouse; const mockClickhouse = { @@ -14,7 +14,7 @@ describe('AnalyticRepository 테스트', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - AnalyticRepository, + AnalyticsRepository, { provide: Clickhouse, useValue: mockClickhouse, @@ -22,7 +22,7 @@ describe('AnalyticRepository 테스트', () => { ], }).compile(); - repository = module.get(AnalyticRepository); + repository = module.get(AnalyticsRepository); clickhouse = module.get(Clickhouse); }); diff --git a/backend/console-server/src/log/analytic/analytic.repository.ts b/backend/console-server/src/log/analytics/analytics.repository.ts similarity index 95% rename from backend/console-server/src/log/analytic/analytic.repository.ts rename to backend/console-server/src/log/analytics/analytics.repository.ts index 15e16cc6..39f6acf4 100644 --- a/backend/console-server/src/log/analytic/analytic.repository.ts +++ b/backend/console-server/src/log/analytics/analytics.repository.ts @@ -4,7 +4,7 @@ import { TimeSeriesQueryBuilder } from '../../clickhouse/query-builder/time-seri import { DauMetric } from './metric/dau.metric'; @Injectable() -export class AnalyticRepository { +export class AnalyticsRepository { constructor(private readonly clickhouse: Clickhouse) {} async findDAUByProject(domain: string, date: string) { diff --git a/backend/console-server/src/log/analytic/analytic.service.spec.ts b/backend/console-server/src/log/analytics/analytics.service.spec.ts similarity index 93% rename from backend/console-server/src/log/analytic/analytic.service.spec.ts rename to backend/console-server/src/log/analytics/analytics.service.spec.ts index d1b2bf9c..72f796a4 100644 --- a/backend/console-server/src/log/analytic/analytic.service.spec.ts +++ b/backend/console-server/src/log/analytics/analytics.service.spec.ts @@ -1,13 +1,13 @@ -import { AnalyticService } from './analytic.service'; -import { AnalyticRepository } from './analytic.repository'; +import { AnalyticsService } from './analytics.service'; +import { AnalyticsRepository } from './analytics.repository'; import type { TestingModule } from '@nestjs/testing'; import { Test } from '@nestjs/testing'; import { getRepositoryToken } from '@nestjs/typeorm'; import { Project } from '../../project/entities/project.entity'; import { NotFoundException } from '@nestjs/common'; -describe('AnalyticService 테스트', () => { - let service: AnalyticService; +describe('AnalyticsService 테스트', () => { + let service: AnalyticsService; const mockLogRepository = { findDAUByProject: jest.fn(), @@ -16,9 +16,9 @@ describe('AnalyticService 테스트', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - AnalyticService, + AnalyticsService, { - provide: AnalyticRepository, + provide: AnalyticsRepository, useValue: mockLogRepository, }, { @@ -28,7 +28,7 @@ describe('AnalyticService 테스트', () => { ], }).compile(); - service = module.get(AnalyticService); + service = module.get(AnalyticsService); jest.clearAllMocks(); }); diff --git a/backend/console-server/src/log/analytic/analytic.service.ts b/backend/console-server/src/log/analytics/analytics.service.ts similarity index 87% rename from backend/console-server/src/log/analytic/analytic.service.ts rename to backend/console-server/src/log/analytics/analytics.service.ts index 31fd4391..fc98f175 100644 --- a/backend/console-server/src/log/analytic/analytic.service.ts +++ b/backend/console-server/src/log/analytics/analytics.service.ts @@ -1,4 +1,4 @@ -import { AnalyticRepository } from './analytic.repository'; +import { AnalyticsRepository } from './analytics.repository'; import { Injectable, NotFoundException } from '@nestjs/common'; import { GetProjectDAU } from './dto/get-project-dau.dto'; import { plainToInstance } from 'class-transformer'; @@ -8,11 +8,11 @@ import { InjectRepository } from '@nestjs/typeorm'; import { Project } from '../../project/entities/project.entity'; @Injectable() -export class AnalyticService { +export class AnalyticsService { constructor( @InjectRepository(Project) private readonly projectRepository: Repository, - private readonly analyticRepository: AnalyticRepository, + private readonly analyticRepository: AnalyticsRepository, ) {} async getProjectDAU(getProjectDAU: GetProjectDAU) { diff --git a/backend/console-server/src/log/analytic/dto/get-project-dau-response.dto.ts b/backend/console-server/src/log/analytics/dto/get-project-dau-response.dto.ts similarity index 100% rename from backend/console-server/src/log/analytic/dto/get-project-dau-response.dto.ts rename to backend/console-server/src/log/analytics/dto/get-project-dau-response.dto.ts diff --git a/backend/console-server/src/log/analytic/dto/get-project-dau.dto.ts b/backend/console-server/src/log/analytics/dto/get-project-dau.dto.ts similarity index 100% rename from backend/console-server/src/log/analytic/dto/get-project-dau.dto.ts rename to backend/console-server/src/log/analytics/dto/get-project-dau.dto.ts diff --git a/backend/console-server/src/log/analytic/metric/dau.metric.ts b/backend/console-server/src/log/analytics/metric/dau.metric.ts similarity index 100% rename from backend/console-server/src/log/analytic/metric/dau.metric.ts rename to backend/console-server/src/log/analytics/metric/dau.metric.ts diff --git a/backend/console-server/src/log/log.module.ts b/backend/console-server/src/log/log.module.ts index 90d31169..1a211716 100644 --- a/backend/console-server/src/log/log.module.ts +++ b/backend/console-server/src/log/log.module.ts @@ -6,7 +6,7 @@ import { ClickhouseModule } from '../clickhouse/clickhouse.module'; import { ElapsedTimeModule } from './elapsed-time/elapsed-time.module'; import { TrafficModule } from './traffic/traffic.module'; import { SuccessRateModule } from './success-rate/success-rate.module'; -import { AnalyticModule } from './analytic/analytic.module'; +import { AnalyticsModule } from './analytics/analytics.module'; @Module({ imports: [ @@ -15,7 +15,7 @@ import { AnalyticModule } from './analytic/analytic.module'; ElapsedTimeModule, TrafficModule, SuccessRateModule, - AnalyticModule, + AnalyticsModule, ], controllers: [LogController], }) From b3a4b2fb38643ad3c9b6e64e66436f137f2a7011 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 00:28:43 +0900 Subject: [PATCH 06/11] =?UTF-8?q?chore:=20success-rate=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20prefix=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/log/success-rate/success-rate.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/console-server/src/log/success-rate/success-rate.controller.ts b/backend/console-server/src/log/success-rate/success-rate.controller.ts index b00e5f35..6c324975 100644 --- a/backend/console-server/src/log/success-rate/success-rate.controller.ts +++ b/backend/console-server/src/log/success-rate/success-rate.controller.ts @@ -10,7 +10,7 @@ import { GetProjectSuccessRateDto } from './dto/get-project-success-rate.dto'; export class SuccessRateController { constructor(private readonly successRateService: SuccessRateService) {} - @Get('/success-rate') + @Get('') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: '기수 내 응답 성공률', @@ -25,7 +25,7 @@ export class SuccessRateController { return await this.successRateService.getSuccessRate(getSuccessRateDto); } - @Get('/success-rate/project') + @Get('/project') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: '프로젝트 별 응답 성공률', From 18f8598e4208e9491e9abc50dce0126a4c09f187 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 00:29:44 +0900 Subject: [PATCH 07/11] =?UTF-8?q?feat:=20elapsed-time,=20success-rate=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=EB=8B=A8=EC=97=90=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=BA=90=EC=8B=9C=20Interceptor=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20-=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=9A=A9?= =?UTF-8?q?=EC=9E=85=EB=8B=88=EB=8B=A4.=20=EC=BA=90=EC=8B=9C=EC=A0=95?= =?UTF-8?q?=EC=B1=85=EC=9D=80=20=ED=95=A8=EA=BB=98=20=EB=8B=A4=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=98=EB=85=BC=ED=95=B4=EB=B3=B4=EC=95=84=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/log/elapsed-time/elapsed-time.controller.ts | 4 +++- .../src/log/success-rate/success-rate.controller.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/console-server/src/log/elapsed-time/elapsed-time.controller.ts b/backend/console-server/src/log/elapsed-time/elapsed-time.controller.ts index 5a2a330f..f3508516 100644 --- a/backend/console-server/src/log/elapsed-time/elapsed-time.controller.ts +++ b/backend/console-server/src/log/elapsed-time/elapsed-time.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, HttpCode, HttpStatus, Query } from '@nestjs/common'; +import { Controller, Get, HttpCode, HttpStatus, Query, UseInterceptors } from '@nestjs/common'; import { ApiOperation, ApiResponse } from '@nestjs/swagger'; import { GetAvgElapsedTimeResponseDto } from './dto/get-avg-elapsed-time-response.dto'; import { GetAvgElapsedTimeDto } from './dto/get-avg-elapsed-time.dto'; @@ -7,8 +7,10 @@ import { GetTop5ElapsedTime } from './dto/get-top5-elapsed.time'; import { GetTop5ElapsedTimeDto } from './dto/get-top5-elapsed-time.dto'; import { GetPathElapsedTimeResponseDto } from './dto/get-path-elapsed-time-response.dto'; import { GetPathElapsedTimeRank } from './dto/get-path-elapsed-time.rank'; +import { CacheInterceptor } from '@nestjs/cache-manager'; @Controller('elapsed-time') +@UseInterceptors(CacheInterceptor) export class ElapsedTimeController { constructor(private readonly elapsedTimeService: ElapsedTimeService) {} diff --git a/backend/console-server/src/log/success-rate/success-rate.controller.ts b/backend/console-server/src/log/success-rate/success-rate.controller.ts index 6c324975..589cf5e0 100644 --- a/backend/console-server/src/log/success-rate/success-rate.controller.ts +++ b/backend/console-server/src/log/success-rate/success-rate.controller.ts @@ -1,12 +1,14 @@ -import { Controller, Get, HttpCode, HttpStatus, Query } from '@nestjs/common'; +import { Controller, Get, HttpCode, HttpStatus, Query, UseInterceptors } from '@nestjs/common'; import { SuccessRateService } from './success-rate.service'; import { ApiOperation, ApiResponse } from '@nestjs/swagger'; import { GetSuccessRateResponseDto } from './dto/get-success-rate-response.dto'; import { GetSuccessRateDto } from './dto/get-success-rate.dto'; import { GetProjectSuccessRateResponseDto } from './dto/get-project-success-rate-response.dto'; import { GetProjectSuccessRateDto } from './dto/get-project-success-rate.dto'; +import { CacheInterceptor } from '@nestjs/cache-manager'; @Controller('success-rate') +@UseInterceptors(CacheInterceptor) export class SuccessRateController { constructor(private readonly successRateService: SuccessRateService) {} From 93ae2f435f8744655cac9ffafef2284e16045d38 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 00:58:28 +0900 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20CacheModule=EC=97=90=20RedisClient?= =?UTF-8?q?Options=20=ED=83=80=EC=9E=85=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=20=EB=84=98=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/package-lock.json | 1 + backend/console-server/package.json | 1 + backend/console-server/src/app.module.ts | 3 ++- backend/console-server/src/log/traffic/traffic.service.ts | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/console-server/package-lock.json b/backend/console-server/package-lock.json index 45f9f509..9df5528c 100644 --- a/backend/console-server/package-lock.json +++ b/backend/console-server/package-lock.json @@ -26,6 +26,7 @@ "handlebars": "^4.7.8", "mysql2": "^3.11.4", "nodemailer": "^6.9.16", + "redis": "^4.7.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "sqlite3": "^5.1.7", diff --git a/backend/console-server/package.json b/backend/console-server/package.json index dccdbaf4..a0310d61 100644 --- a/backend/console-server/package.json +++ b/backend/console-server/package.json @@ -38,6 +38,7 @@ "handlebars": "^4.7.8", "mysql2": "^3.11.4", "nodemailer": "^6.9.16", + "redis": "^4.7.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "sqlite3": "^5.1.7", diff --git a/backend/console-server/src/app.module.ts b/backend/console-server/src/app.module.ts index b873b7fb..5d108e89 100644 --- a/backend/console-server/src/app.module.ts +++ b/backend/console-server/src/app.module.ts @@ -12,13 +12,14 @@ import { LogModule } from './log/log.module'; import clickhouseConfig from './config/clickhouse.config'; import { CacheModule } from '@nestjs/cache-manager'; import redisConfig from './config/redis.config'; +import { RedisClientOptions } from 'redis'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: [mailerConfig, clickhouseConfig] }), TypeOrmModule.forRootAsync(typeOrmConfig.asProvider()), ClickhouseModule, - CacheModule.registerAsync({ + CacheModule.registerAsync({ isGlobal: true, ...redisConfig.asProvider(), }), diff --git a/backend/console-server/src/log/traffic/traffic.service.ts b/backend/console-server/src/log/traffic/traffic.service.ts index 04d6c8b8..011cc5b8 100644 --- a/backend/console-server/src/log/traffic/traffic.service.ts +++ b/backend/console-server/src/log/traffic/traffic.service.ts @@ -6,7 +6,7 @@ import { GetTrafficByGenerationResponseDto } from './dto/get-traffic-by-generati import type { GetTrafficDailyDifferenceDto } from './dto/get-traffic-daily-difference.dto'; import { GetTrafficDailyDifferenceResponseDto } from './dto/get-traffic-daily-difference-response.dto'; import type { GetTrafficByProjectDto } from './dto/get-traffic-by-project.dto'; -import { Inject, Injectable, NotFoundException } from '@nestjs/common'; +import { Injectable, NotFoundException } from '@nestjs/common'; import { GetTrafficByProjectResponseDto, TrafficCountByTimeunit, From 289e5fa819e4f88a5261cd20371c0d8de90f3b3a Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 01:07:46 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20config=EC=97=90=20ttl=20=EC=9E=98?= =?UTF-8?q?=EB=AA=BB=EB=90=9C=20=EC=9C=84=EC=B9=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/package-lock.json | 1 - backend/console-server/package.json | 1 - backend/console-server/src/app.module.ts | 3 +-- backend/console-server/src/config/redis.config.ts | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/console-server/package-lock.json b/backend/console-server/package-lock.json index 9df5528c..45f9f509 100644 --- a/backend/console-server/package-lock.json +++ b/backend/console-server/package-lock.json @@ -26,7 +26,6 @@ "handlebars": "^4.7.8", "mysql2": "^3.11.4", "nodemailer": "^6.9.16", - "redis": "^4.7.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "sqlite3": "^5.1.7", diff --git a/backend/console-server/package.json b/backend/console-server/package.json index a0310d61..dccdbaf4 100644 --- a/backend/console-server/package.json +++ b/backend/console-server/package.json @@ -38,7 +38,6 @@ "handlebars": "^4.7.8", "mysql2": "^3.11.4", "nodemailer": "^6.9.16", - "redis": "^4.7.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "sqlite3": "^5.1.7", diff --git a/backend/console-server/src/app.module.ts b/backend/console-server/src/app.module.ts index 5d108e89..b873b7fb 100644 --- a/backend/console-server/src/app.module.ts +++ b/backend/console-server/src/app.module.ts @@ -12,14 +12,13 @@ import { LogModule } from './log/log.module'; import clickhouseConfig from './config/clickhouse.config'; import { CacheModule } from '@nestjs/cache-manager'; import redisConfig from './config/redis.config'; -import { RedisClientOptions } from 'redis'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: [mailerConfig, clickhouseConfig] }), TypeOrmModule.forRootAsync(typeOrmConfig.asProvider()), ClickhouseModule, - CacheModule.registerAsync({ + CacheModule.registerAsync({ isGlobal: true, ...redisConfig.asProvider(), }), diff --git a/backend/console-server/src/config/redis.config.ts b/backend/console-server/src/config/redis.config.ts index dd93f8e7..c0e4a60e 100644 --- a/backend/console-server/src/config/redis.config.ts +++ b/backend/console-server/src/config/redis.config.ts @@ -7,10 +7,10 @@ export default registerAs('redisConfig', async () => { host: process.env.REDIS_HOST || 'localhost', port: Number(process.env.REDIS_PORT) || 6379, }, + ttl: 60 * 1000, }); return { store: store, - ttl: 3 * 60 * 1000, }; }); From 50e12f0b673fb4aedfeeb51c5bc53fb41d3c820b Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 01:16:58 +0900 Subject: [PATCH 10/11] =?UTF-8?q?chore:=20linter=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/src/app.service.ts | 6 +++--- .../src/log/elapsed-time/elapsed-time.service.ts | 2 +- .../dto/get-traffic-daily-difference-response.dto.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/console-server/src/app.service.ts b/backend/console-server/src/app.service.ts index 927d7cca..61b7a5b6 100644 --- a/backend/console-server/src/app.service.ts +++ b/backend/console-server/src/app.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; @Injectable() export class AppService { - getHello(): string { - return 'Hello World!'; - } + getHello(): string { + return 'Hello World!'; + } } diff --git a/backend/console-server/src/log/elapsed-time/elapsed-time.service.ts b/backend/console-server/src/log/elapsed-time/elapsed-time.service.ts index a4bbd34f..055a51b6 100644 --- a/backend/console-server/src/log/elapsed-time/elapsed-time.service.ts +++ b/backend/console-server/src/log/elapsed-time/elapsed-time.service.ts @@ -6,7 +6,7 @@ import type { GetTop5ElapsedTimeDto } from './dto/get-top5-elapsed-time.dto'; import { GetTop5ElapsedTime, ProjectElapsedTime } from './dto/get-top5-elapsed.time'; import type { Repository } from 'typeorm'; import type { GetPathElapsedTimeRank } from './dto/get-path-elapsed-time.rank'; -import { Inject, Injectable, NotFoundException } from '@nestjs/common'; +import { Injectable, NotFoundException } from '@nestjs/common'; import { GetPathElapsedTimeResponseDto, PathResponseTime, diff --git a/backend/console-server/src/log/traffic/dto/get-traffic-daily-difference-response.dto.ts b/backend/console-server/src/log/traffic/dto/get-traffic-daily-difference-response.dto.ts index 6972cf7b..02bb1293 100644 --- a/backend/console-server/src/log/traffic/dto/get-traffic-daily-difference-response.dto.ts +++ b/backend/console-server/src/log/traffic/dto/get-traffic-daily-difference-response.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { Expose } from 'class-transformer'; -import { IsNotEmpty, IsNumber, IsString } from 'class-validator'; +import { IsNotEmpty, IsString } from 'class-validator'; export class GetTrafficDailyDifferenceResponseDto { @ApiProperty({ From d85444a365688a93f649fdecec0a6655215a9b7a Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Mon, 25 Nov 2024 01:59:39 +0900 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=AA=A8=EB=93=88?= =?UTF-8?q?=EC=97=90=20mockCacheManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/log/analytics/analytics.controller.spec.ts | 11 +++++++++++ .../log/elapsed-time/elapsed-time.controller.spec.ts | 11 +++++++++++ .../log/success-rate/success-rate.controller.spec.ts | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/backend/console-server/src/log/analytics/analytics.controller.spec.ts b/backend/console-server/src/log/analytics/analytics.controller.spec.ts index 577ab274..8aa59df3 100644 --- a/backend/console-server/src/log/analytics/analytics.controller.spec.ts +++ b/backend/console-server/src/log/analytics/analytics.controller.spec.ts @@ -2,6 +2,7 @@ import type { TestingModule } from '@nestjs/testing'; import { Test } from '@nestjs/testing'; import { AnalyticsService } from './analytics.service'; import { AnalyticsController } from './analytics.controller'; +import { CACHE_MANAGER } from '@nestjs/cache-manager'; describe('AnalyticsController 테스트', () => { let controller: AnalyticsController; @@ -11,6 +12,12 @@ describe('AnalyticsController 테스트', () => { getProjectDAU: jest.fn(), }; + const mockCacheManager = { + get: jest.fn(), + set: jest.fn(), + del: jest.fn(), + }; + beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [AnalyticsController], @@ -19,6 +26,10 @@ describe('AnalyticsController 테스트', () => { provide: AnalyticsService, useValue: mockLogService, }, + { + provide: CACHE_MANAGER, + useValue: mockCacheManager, + }, ], }).compile(); diff --git a/backend/console-server/src/log/elapsed-time/elapsed-time.controller.spec.ts b/backend/console-server/src/log/elapsed-time/elapsed-time.controller.spec.ts index 9731e8df..47be0238 100644 --- a/backend/console-server/src/log/elapsed-time/elapsed-time.controller.spec.ts +++ b/backend/console-server/src/log/elapsed-time/elapsed-time.controller.spec.ts @@ -5,6 +5,7 @@ import { Test } from '@nestjs/testing'; import { HttpStatus } from '@nestjs/common'; import { plainToInstance } from 'class-transformer'; import { GetAvgElapsedTimeDto } from './dto/get-avg-elapsed-time.dto'; +import { CACHE_MANAGER } from '@nestjs/cache-manager'; describe('ElapsedTimeController 테스트', () => { let controller: ElapsedTimeController; @@ -16,6 +17,12 @@ describe('ElapsedTimeController 테스트', () => { getTop5ElapsedTime: jest.fn(), }; + const mockCacheManager = { + get: jest.fn(), + set: jest.fn(), + del: jest.fn(), + }; + beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [ElapsedTimeController], @@ -24,6 +31,10 @@ describe('ElapsedTimeController 테스트', () => { provide: ElapsedTimeService, useValue: mockElapsedTimeService, }, + { + provide: CACHE_MANAGER, + useValue: mockCacheManager, + }, ], }).compile(); diff --git a/backend/console-server/src/log/success-rate/success-rate.controller.spec.ts b/backend/console-server/src/log/success-rate/success-rate.controller.spec.ts index f2abe0e4..8490d3db 100644 --- a/backend/console-server/src/log/success-rate/success-rate.controller.spec.ts +++ b/backend/console-server/src/log/success-rate/success-rate.controller.spec.ts @@ -2,6 +2,7 @@ import { SuccessRateController } from './success-rate.controller'; import { SuccessRateService } from './success-rate.service'; import type { TestingModule } from '@nestjs/testing'; import { Test } from '@nestjs/testing'; +import { CACHE_MANAGER } from '@nestjs/cache-manager'; describe('SuccessRateController 테스트', () => { let controller: SuccessRateController; @@ -12,6 +13,12 @@ describe('SuccessRateController 테스트', () => { getProjectSuccessRate: jest.fn(), }; + const mockCacheManager = { + get: jest.fn(), + set: jest.fn(), + del: jest.fn(), + }; + beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [SuccessRateController], @@ -20,6 +27,10 @@ describe('SuccessRateController 테스트', () => { provide: SuccessRateService, useValue: mockSuccessRateService, }, + { + provide: CACHE_MANAGER, + useValue: mockCacheManager, + }, ], }).compile();