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

Commit 382dd87

Browse files
author
noah
committed
Fix to eager load edges
1 parent 306c289 commit 382dd87

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

internal/interactor/perm.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ func (i *PermInteractor) ResyncPerms(ctx context.Context) error {
4747
}
4848

4949
for _, p := range perms {
50-
if p.Edges.Repo != nil && i.matchOrg(p.Edges.Repo.Namespace) {
50+
if p.Edges.Repo == nil {
51+
i.log.Warn("Failed to eager loading for the perm.", zap.Int("perm_id", p.ID))
52+
continue
53+
}
54+
55+
if i.matchOrg(p.Edges.Repo.Namespace) {
5156
continue
5257
}
5358

internal/pkg/store/perm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func (s *Store) ListPerms(ctx context.Context, opt *i.ListOptions) ([]*ent.Perm,
1717
return s.c.Perm.Query().
1818
Limit(opt.PerPage).
1919
Offset(offset(opt.Page, opt.PerPage)).
20+
WithRepo().
21+
WithUser().
2022
All(ctx)
2123
}
2224

0 commit comments

Comments
 (0)