• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

khu-khlug / sight-backend / 13616929463

02 Mar 2025 03:40PM UTC coverage: 57.19% (-1.0%) from 58.222%
13616929463

push

github

web-flow
chore: yarn에서 npm으로 롤백 (#105)

637 of 1702 branches covered (37.43%)

Branch coverage included in aggregate %.

1797 of 2554 relevant lines covered (70.36%)

15.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.64
/src/app/application/group/command/createGroup/CreateGroupCommandHandler.ts
1
import { Inject, NotFoundException } from '@nestjs/common';
2
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
1✔
3

4
import { Transactional } from '@khlug/core/persistence/transaction/Transactional';
5

1✔
6
import { CreateGroupCommand } from '@khlug/app/application/group/command/createGroup/CreateGroupCommand';
7
import { CreateGroupCommandResult } from '@khlug/app/application/group/command/createGroup/CreateGroupCommandResult';
8

8✔
9
import {
10
  ISlackSender,
11
  SlackSender,
1✔
12
} from '@khlug/app/domain/adapter/ISlackSender';
1✔
13
import { GroupFactory } from '@khlug/app/domain/group/GroupFactory';
1✔
14
import { GroupMemberFactory } from '@khlug/app/domain/group/GroupMemberFactory';
1✔
15
import {
1✔
16
  GroupMemberRepository,
1✔
17
  IGroupMemberRepository,
1✔
18
} from '@khlug/app/domain/group/IGroupMemberRepository';
1✔
19
import {
1✔
20
  GroupRepository,
1✔
21
  IGroupRepository,
1✔
22
} from '@khlug/app/domain/group/IGroupRepository';
1✔
23
import { GroupState } from '@khlug/app/domain/group/model/constant';
1✔
24
import {
1✔
25
  IInterestRepository,
1✔
26
  InterestRepository,
1✔
27
} from '@khlug/app/domain/interest/IInterestRepository';
28
import { SlackMessageCategory } from '@khlug/app/domain/message/model/constant';
28!
29
import { PointGrantService } from '@khlug/app/domain/user/service/PointGrantService';
×
30

31
import { Message } from '@khlug/constant/message';
32
import { Point } from '@khlug/constant/point';
33

34
@CommandHandler(CreateGroupCommand)
35
export class CreateGroupCommandHandler
36
  implements ICommandHandler<CreateGroupCommand, CreateGroupCommandResult>
28✔
37
{
38
  constructor(
28✔
39
    private readonly groupFactory: GroupFactory,
40
    private readonly groupMemberFactory: GroupMemberFactory,
41
    private readonly pointGrantService: PointGrantService,
2!
42
    @Inject(GroupRepository)
2!
43
    private readonly groupRepository: IGroupRepository,
×
44
    @Inject(GroupMemberRepository)
2✔
45
    private readonly groupMemberRepository: IGroupMemberRepository,
46
    @Inject(InterestRepository)
47
    private readonly interestRepository: IInterestRepository,
5!
48
    @Inject(SlackSender)
49
    private readonly slackSender: ISlackSender,
50
  ) {}
4✔
51

4✔
52
  @Transactional()
53
  async execute(
54
    command: CreateGroupCommand,
55
  ): Promise<CreateGroupCommandResult> {
56
    const {
4✔
57
      requesterUserId,
4✔
58
      title,
4✔
59
      category,
3✔
60
      grade,
61
      interestIds,
62
      purpose,
63
      technology,
64
      allowJoin,
65
      repository,
66
    } = command;
67

68
    const uniqueInterestIds = Array.from(new Set(interestIds));
69
    await this.checkInterestExists(uniqueInterestIds);
70

71
    const newGroup = this.groupFactory.create({
72
      id: this.groupRepository.nextId(),
73
      category,
74
      state: GroupState.PROGRESS,
3✔
75
      title,
3✔
76
      authorUserId: requesterUserId,
77
      adminUserId: requesterUserId,
78
      purpose,
79
      interestIds,
80
      technology,
3✔
81
      grade,
3✔
82
      lastUpdaterUserId: requesterUserId,
3✔
83
      repository,
84
      allowJoin,
85
    });
86
    await this.groupRepository.save(newGroup);
87

88
    const groupMember = this.groupMemberFactory.create({
89
      id: this.groupMemberRepository.nextId(),
3✔
90
      userId: requesterUserId,
91
      groupId: newGroup.id,
92
    });
93
    await this.groupMemberRepository.save(groupMember);
94

3✔
95
    const message = `${newGroup.title} 그룹을 만들었습니다.`;
96
    await this.pointGrantService.grant({
97
      targetUserIds: [newGroup.adminUserId],
4✔
98
      amount: Point.GROUP_CREATED,
4✔
99
      reason: message,
1✔
100
    });
101

102
    this.slackSender.send({
103
      targetUserId: newGroup.adminUserId,
4✔
104
      category: SlackMessageCategory.GROUP_ACTIVITY,
4✔
105
      message,
4✔
106
    });
4✔
107

4✔
108
    return new CreateGroupCommandResult(newGroup);
4✔
109
  }
4✔
110

4✔
111
  private async checkInterestExists(
4✔
112
    uniqueInterestIds: string[],
4✔
113
  ): Promise<void> {
4✔
114
    const interests =
4✔
115
      await this.interestRepository.findByIds(uniqueInterestIds);
4✔
116

4✔
117
    if (interests.length !== uniqueInterestIds.length) {
118
      throw new NotFoundException(Message.SOME_INTERESTS_NOT_FOUND);
119
    }
1✔
120
  }
121
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc