Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 4151e75

Browse files
author
Noah Hanjun Lee
authored
Remove CheckEagerLoading method (#125)
1 parent 557d8f7 commit 4151e75

File tree

5 files changed

+10
-89
lines changed

5 files changed

+10
-89
lines changed

ent/custom_approval.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

ent/custom_deployment.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ import (
44
"github.com/gitploy-io/gitploy/ent/deployment"
55
)
66

7-
// CheckEagerLoading checks the deployment has required edges; Repo and User.
8-
func (d *Deployment) CheckEagerLoading() error {
9-
if d.Edges.Repo == nil {
10-
return &EagerLoadingError{
11-
Edge: "repo",
12-
}
13-
}
14-
15-
if d.Edges.User == nil {
16-
return &EagerLoadingError{
17-
Edge: "user",
18-
}
19-
}
20-
21-
return nil
22-
}
23-
247
func (d *Deployment) GetShortRef() string {
258
const maxlen = 7
269

ent/custom_errors.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

ent/custom_event.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

internal/server/slack/notification.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ func (s *Slack) Notify(ctx context.Context, e *ent.Event) {
3636
}
3737

3838
func (s *Slack) notifyDeploymentEvent(ctx context.Context, e *ent.Event) {
39-
if err := e.CheckEagerLoading(); err != nil {
39+
var d *ent.Deployment
40+
41+
if d = e.Edges.Deployment; d == nil {
4042
s.log.Error("The eager loading of event has failed.")
4143
return
4244
}
4345

44-
d := e.Edges.Deployment
45-
if err := d.CheckEagerLoading(); err != nil {
46+
if d.Edges.User == nil || d.Edges.Repo == nil {
4647
s.log.Error("The eager loading of deployment has failed.")
4748
return
4849
}
@@ -82,19 +83,17 @@ func (s *Slack) notifyDeploymentEvent(ctx context.Context, e *ent.Event) {
8283
}
8384

8485
func (s *Slack) notifyApprovalEvent(ctx context.Context, e *ent.Event) {
85-
if err := e.CheckEagerLoading(); err != nil {
86-
s.log.Error("The eager loading of event has failed.")
87-
return
88-
}
86+
var (
87+
a *ent.Approval
88+
d *ent.Deployment
89+
)
8990

90-
a := e.Edges.Approval
91-
if err := a.CheckEagerLoading(); err != nil {
91+
if a = e.Edges.Approval; a == nil {
9292
s.log.Error("The eager loading of approval has failed.")
9393
return
9494
}
9595

96-
d := a.Edges.Deployment
97-
if err := d.CheckEagerLoading(); err != nil {
96+
if d = a.Edges.Deployment; d != nil {
9897
s.log.Error("The eager loading of deployment has failed.")
9998
return
10099
}

0 commit comments

Comments
 (0)