fix(dakao): hide started matches from schedule #6
No files matched your search
@@ -22,6 +22,33 @@ function makeHandler(params: {
|
||||
}
|
||||
|
||||
describe('MatchListHandler', () => {
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('queries only matches scheduled at or after command processing time', async () => {
|
||||
const now = new Date('2026-07-25T07:30:00.000Z');
|
||||
jest.useFakeTimers().setSystemTime(now);
|
||||
const communityId = objectId('111111111111111111111111');
|
||||
const list = jest.fn().mockResolvedValue([]);
|
||||
const handler = makeHandler({
|
||||
matchService: { list },
|
||||
});
|
||||
|
||||
await handler.handle({
|
||||
communityId,
|
||||
senderUserId: 'kakao-user-1',
|
||||
senderNickname: '프리리',
|
||||
});
|
||||
|
||||
expect(list).toHaveBeenCalledWith({
|
||||
communityId,
|
||||
status: 'recruiting',
|
||||
scheduledFrom: now,
|
||||
limit: 10,
|
||||
});
|
||||
});
|
||||
|
||||
it('prints short codes, compact KST dates, and short links', async () => {
|
||||
const match = {
|
||||
_id: objectId('333333333333333333333333'),
|
||||
|
||||
@@ -19,9 +19,11 @@ export class MatchListHandler {
|
||||
senderUserId: string;
|
||||
senderNickname: string;
|
||||
}): Promise<DakaoSegment[]> {
|
||||
const scheduledFrom = new Date();
|
||||
const matches = await this.matchService.list({
|
||||
communityId: params.communityId,
|
||||
status: 'recruiting',
|
||||
scheduledFrom,
|
||||
limit: 10,
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# Spec: Dakao Upcoming Internal Match List
|
||||
|
||||
## Objective
|
||||
|
||||
When a user sends `!내전 일정`, return only recruiting matches whose scheduled
|
||||
start is not earlier than the command processing time. Matches that have already
|
||||
started must not consume the ten-result query limit or appear in the response.
|
||||
|
||||
## Approved Product Decisions
|
||||
|
||||
- Capture the command processing time once before querying matches.
|
||||
- Exclude `scheduledAt < now`.
|
||||
- Include `scheduledAt === now` and future matches.
|
||||
- Apply the boundary only to the Dakao `!내전 일정` command.
|
||||
- Preserve the existing recruiting status, result limit, ordering, formatting,
|
||||
short-code generation, and short-link behavior.
|
||||
|
||||
## Commands
|
||||
|
||||
- Focused test:
|
||||
`pnpm --filter api exec jest src/modules/dakao/handlers/match-list.handler.spec.ts --runInBand`
|
||||
- API lint:
|
||||
`pnpm --filter api exec eslint "{src,apps,libs,test}/**/*.ts" --max-warnings=0`
|
||||
- API build: `pnpm --filter api build`
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `apps/api/src/modules/dakao/handlers/match-list.handler.ts` owns the command
|
||||
query and response formatting.
|
||||
- `apps/api/src/modules/dakao/handlers/match-list.handler.spec.ts` verifies the
|
||||
command boundary and presentation.
|
||||
- `apps/api/src/modules/match/match.service.ts` translates `scheduledFrom` into a
|
||||
MongoDB `$gte` filter.
|
||||
|
||||
## Code Style
|
||||
|
||||
Pass the captured boundary through the existing list contract:
|
||||
|
||||
```ts
|
||||
const scheduledFrom = new Date();
|
||||
await matchService.list({ communityId, scheduledFrom });
|
||||
```
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Freeze the system clock in the handler unit test.
|
||||
- Assert that the exact frozen time is passed as `scheduledFrom`.
|
||||
- Rely on the existing `MatchService` test that verifies `scheduledFrom` becomes
|
||||
`{ scheduledAt: { $gte: scheduledFrom } }`.
|
||||
- Run the focused handler test, full API lint, and API build.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Always: filter before applying the result limit and use one captured time.
|
||||
- Ask first: change ordering, statuses, limit, or response wording.
|
||||
- Never: hide the requirement with an ESLint exception or filter only after the
|
||||
limited database query.
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- A match scheduled before command processing time is not queried.
|
||||
- A match scheduled exactly at command processing time remains eligible.
|
||||
- Existing command formatting and link tests continue to pass.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
Reference in new issue
Block a user