-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ daily team close records 추가를 통한 home team close records last 추가
- #392
- Loading branch information
Showing
10 changed files
with
176 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { DateRange } from 'src/dateRange/dtos/dateRange.dto'; | ||
|
||
export type FindTeamCloseCountByDateInput = DateRange; | ||
|
||
export type FindTeamCloseCountByDateOutput = { | ||
date: Date; | ||
count: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { MongooseModule } from '@nestjs/mongoose'; | ||
import { DailyTeamCloseCountService } from './dailyTeamCloseCount.service'; | ||
import { DailyTeamCloseClountDaoImpl } from './db/dailyTeamCloseCount.database.dao'; | ||
import { | ||
dailyTeamCloseCountSchema, | ||
mv_daily_team_close_counts, | ||
} from './db/dailyTeamCloseCount.database.schema'; | ||
|
||
@Module({ | ||
imports: [ | ||
MongooseModule.forFeature([ | ||
{ | ||
name: mv_daily_team_close_counts.name, | ||
schema: dailyTeamCloseCountSchema, | ||
}, | ||
]), | ||
], | ||
providers: [DailyTeamCloseCountService, DailyTeamCloseClountDaoImpl], | ||
exports: [DailyTeamCloseCountService], | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class | ||
export class DailyTeamCloseCountModule {} |
24 changes: 24 additions & 0 deletions
24
app/src/dailyTeamCloseCount/dailyTeamCloseCount.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { DailyTeamCloseClountDaoImpl } from './db/dailyTeamCloseCount.database.dao'; | ||
import type { IntRecord } from 'src/common/models/common.valueRecord.model'; | ||
import type { DateRange } from 'src/dateRange/dtos/dateRange.dto'; | ||
|
||
@Injectable() | ||
export class DailyTeamCloseCountService { | ||
constructor( | ||
private readonly dailyTeamCloseCountDao: DailyTeamCloseClountDaoImpl, | ||
) {} | ||
|
||
async teamCloseCountRecords({ start, end }: DateRange): Promise<IntRecord[]> { | ||
const teamCloseCounts = | ||
await this.dailyTeamCloseCountDao.findTeamCloseCountsByDate({ | ||
start, | ||
end, | ||
}); | ||
|
||
return teamCloseCounts.map(({ date, count }) => ({ | ||
at: date, | ||
value: count, | ||
})); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/dailyTeamCloseCount/db/dailyTeamCloseCount.database.dao.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { InjectModel } from '@nestjs/mongoose'; | ||
import type { | ||
FindTeamCloseCountByDateInput, | ||
FindTeamCloseCountByDateOutput, | ||
} from '../dailyTeamCloseCount.dto'; | ||
import { mv_daily_team_close_counts } from './dailyTeamCloseCount.database.schema'; | ||
import type { Model } from 'mongoose'; | ||
|
||
export type DailyTeamCloseCountDao = { | ||
findTeamCloseCountsByDate: ( | ||
args: FindTeamCloseCountByDateInput, | ||
) => Promise<FindTeamCloseCountByDateOutput[]>; | ||
}; | ||
|
||
export class DailyTeamCloseClountDaoImpl implements DailyTeamCloseCountDao { | ||
constructor( | ||
@InjectModel(mv_daily_team_close_counts.name) | ||
private readonly dailyTeamCloseCount: Model<mv_daily_team_close_counts>, | ||
) {} | ||
|
||
async findTeamCloseCountsByDate({ | ||
start, | ||
end, | ||
}: FindTeamCloseCountByDateInput): Promise<FindTeamCloseCountByDateOutput[]> { | ||
return await this.dailyTeamCloseCount | ||
.find( | ||
{ | ||
date: { | ||
$gte: start, | ||
$lt: end, | ||
}, | ||
}, | ||
{ | ||
_id: 0, | ||
date: 1, | ||
count: 1, | ||
}, | ||
{ | ||
sort: { _id: 1 }, | ||
}, | ||
) | ||
.lean(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/dailyTeamCloseCount/db/dailyTeamCloseCount.database.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import type { HydratedDocument } from 'mongoose'; | ||
|
||
export type DailyTeamCloseCountDocument = | ||
HydratedDocument<mv_daily_team_close_counts>; | ||
|
||
@Schema({ collection: 'mv_daily_team_close_counts' }) | ||
export class mv_daily_team_close_counts { | ||
@Prop({ required: true }) | ||
count: number; | ||
|
||
@Prop({ required: true }) | ||
date: Date; | ||
} | ||
|
||
export const dailyTeamCloseCountSchema = SchemaFactory.createForClass( | ||
mv_daily_team_close_counts, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters