Monorepo for Tangled tangled.org

draft: appview: service layer #800

open opened by boltless.me targeting master from sl/uvpzuszrulvq

Obviously file naming of appview/web/handler/*.go files are directly against to go convention. Though I think flattening all handler files can significantly reduce the effort involved in file naming and structuring. We are already grouping core services by domains, and doing same for web handers is just over-complicating.

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3m5jyyj76xa22
+29 -19
Interdiff #7 #8
appview/oauth/handler.go

This patch was likely rebased, as context lines do not match.

appview/oauth/session.go

This file has not been changed.

+1
appview/service/issue/errors.go
··· 7 7 ErrForbidden = errors.New("unauthorized operation") 8 8 ErrDatabaseFail = errors.New("db op fail") 9 9 ErrPDSFail = errors.New("pds op fail") 10 + ErrIndexerFail = errors.New("indexer fail") 10 11 ErrValidationFail = errors.New("issue validation fail") 11 12 )
+12 -7
appview/service/issue/issue.go
··· 18 18 "tangled.org/core/appview/session" 19 19 "tangled.org/core/appview/validator" 20 20 "tangled.org/core/idresolver" 21 + "tangled.org/core/orm" 21 22 "tangled.org/core/rbac" 22 23 "tangled.org/core/tid" 23 24 ) ··· 124 125 } 125 126 126 127 func (s *Service) GetIssues(ctx context.Context, repo *models.Repo, searchOpts models.IssueSearchOptions) ([]models.Issue, error) { 127 - l := s.logger.With("method", "EditIssue") 128 + l := s.logger.With("method", "GetIssues") 128 129 129 130 var issues []models.Issue 130 131 var err error ··· 132 133 res, err := s.indexer.Search(ctx, searchOpts) 133 134 if err != nil { 134 135 l.Error("failed to search for issues", "err", err) 135 - return nil, err 136 + return nil, ErrIndexerFail 136 137 } 137 138 l.Debug("searched issues with indexer", "count", len(res.Hits)) 138 - issues, err = db.GetIssues(s.db, db.FilterIn("id", res.Hits)) 139 + issues, err = db.GetIssues(s.db, orm.FilterIn("id", res.Hits)) 139 140 if err != nil { 140 141 l.Error("failed to get issues", "err", err) 141 - return nil, err 142 + return nil, ErrDatabaseFail 142 143 } 143 144 } else { 144 145 openInt := 0 ··· 148 149 issues, err = db.GetIssuesPaginated( 149 150 s.db, 150 151 searchOpts.Page, 151 - db.FilterEq("repo_at", repo.RepoAt()), 152 - db.FilterEq("open", openInt), 152 + orm.FilterEq("repo_at", repo.RepoAt()), 153 + orm.FilterEq("open", openInt), 153 154 ) 154 155 if err != nil { 155 156 l.Error("failed to get issues", "err", err) 156 - return nil, err 157 + return nil, ErrDatabaseFail 157 158 } 158 159 } 159 160 ··· 170 171 sessDid := sess.Data.AccountDID 171 172 l = l.With("did", sessDid) 172 173 174 + mentions, references := s.refResolver.Resolve(ctx, issue.Body) 175 + issue.Mentions = mentions 176 + issue.References = references 177 + 173 178 if sessDid != syntax.DID(issue.Did) { 174 179 l.Error("only author can edit the issue") 175 180 return ErrForbidden
+3 -2
appview/service/issue/state.go
··· 8 8 "tangled.org/core/appview/models" 9 9 "tangled.org/core/appview/pages/repoinfo" 10 10 "tangled.org/core/appview/session" 11 + "tangled.org/core/orm" 11 12 ) 12 13 13 14 func (s *Service) CloseIssue(ctx context.Context, issue *models.Issue) error { ··· 32 33 33 34 err := db.CloseIssues( 34 35 s.db, 35 - db.FilterEq("id", issue.Id), 36 + orm.FilterEq("id", issue.Id), 36 37 ) 37 38 if err != nil { 38 39 l.Error("db.CloseIssues failed", "err", err) ··· 68 69 69 70 err := db.ReopenIssues( 70 71 s.db, 71 - db.FilterEq("id", issue.Id), 72 + orm.FilterEq("id", issue.Id), 72 73 ) 73 74 if err != nil { 74 75 l.Error("db.ReopenIssues failed", "err", err)
appview/service/repo/errors.go

This file has not been changed.

appview/service/repo/repo.go

This file has not been changed.

appview/service/repo/repoinfo.go

This file has not been changed.

appview/session/context.go

This file has not been changed.

appview/session/session.go

This file has not been changed.

appview/state/legacy_bridge.go

This file has not been changed.

appview/web/handler/oauth_client_metadata.go

This file has not been changed.

appview/web/handler/oauth_jwks.go

This file has not been changed.

+4 -3
appview/web/handler/user_repo_issues.go
··· 13 13 "tangled.org/core/appview/session" 14 14 "tangled.org/core/appview/web/request" 15 15 "tangled.org/core/log" 16 + "tangled.org/core/orm" 16 17 ) 17 18 18 19 func RepoIssues(is isvc.Service, rs rsvc.Service, p *pages.Pages, d *db.DB) http.HandlerFunc { ··· 26 27 return 27 28 } 28 29 repoOwnerId, ok := request.OwnerFromContext(ctx) 29 - if !ok { 30 + if !ok { 30 31 l.Error("malformed request") 31 32 p.Error503(w) 32 33 return ··· 56 57 } 57 58 labelDefs, err := db.GetLabelDefinitions( 58 59 d, 59 - db.FilterIn("at_uri", repo.Labels), 60 - db.FilterContains("scope", tangled.RepoIssueNSID), 60 + orm.FilterIn("at_uri", repo.Labels), 61 + orm.FilterContains("scope", tangled.RepoIssueNSID), 61 62 ) 62 63 if err != nil { 63 64 return err
+4 -3
appview/web/handler/user_repo_issues_issue.go
··· 12 12 "tangled.org/core/appview/session" 13 13 "tangled.org/core/appview/web/request" 14 14 "tangled.org/core/log" 15 + "tangled.org/core/orm" 15 16 ) 16 17 17 18 func Issue(s isvc.Service, rs rsvc.Service, p *pages.Pages, d *db.DB) http.HandlerFunc { ··· 25 26 return 26 27 } 27 28 repoOwnerId, ok := request.OwnerFromContext(ctx) 28 - if !ok { 29 + if !ok { 29 30 l.Error("malformed request") 30 31 p.Error503(w) 31 32 return ··· 59 60 60 61 labelDefs, err := db.GetLabelDefinitions( 61 62 d, 62 - db.FilterIn("at_uri", issue.Repo.Labels), 63 - db.FilterContains("scope", tangled.RepoIssueNSID), 63 + orm.FilterIn("at_uri", issue.Repo.Labels), 64 + orm.FilterContains("scope", tangled.RepoIssueNSID), 64 65 ) 65 66 if err != nil { 66 67 l.Error("failed to fetch label defs", "err", err)
appview/web/handler/user_repo_issues_issue_close.go

This file has not been changed.

+1 -1
appview/web/handler/user_repo_issues_issue_edit.go
··· 23 23 return 24 24 } 25 25 repoOwnerId, ok := request.OwnerFromContext(ctx) 26 - if !ok { 26 + if !ok { 27 27 l.Error("malformed request") 28 28 p.Error503(w) 29 29 return
appview/web/handler/user_repo_issues_issue_reopen.go

This file has not been changed.

+1 -1
appview/web/handler/user_repo_issues_new.go
··· 26 26 return fmt.Errorf("malformed request") 27 27 } 28 28 repoOwnerId, ok := request.OwnerFromContext(ctx) 29 - if !ok { 29 + if !ok { 30 30 return fmt.Errorf("malformed request") 31 31 } 32 32 repoinfo, err := rs.GetRepoInfo(ctx, repoOwnerId, repo, "", "", user)
appview/web/middleware/auth.go

This file has not been changed.

appview/web/middleware/ensuredidorhandle.go

This file has not been changed.

appview/web/middleware/log.go

This file has not been changed.

appview/web/middleware/middleware.go

This file has not been changed.

appview/web/middleware/normalize.go

This file has not been changed.

appview/web/middleware/paginate.go

This file has not been changed.

+3 -2
appview/web/middleware/resolve.go
··· 12 12 "tangled.org/core/appview/web/request" 13 13 "tangled.org/core/idresolver" 14 14 "tangled.org/core/log" 15 + "tangled.org/core/orm" 15 16 ) 16 17 17 18 func ResolveIdent( ··· 60 61 61 62 repo, err := db.GetRepo( 62 63 e, 63 - db.FilterEq("did", repoOwner.DID.String()), 64 - db.FilterEq("name", repoName), 64 + orm.FilterEq("did", repoOwner.DID.String()), 65 + orm.FilterEq("name", repoName), 65 66 ) 66 67 if err != nil { 67 68 l.Warn("failed to resolve repo", "err", err)
appview/web/request/context.go

This file has not been changed.

appview/web/routes.go

This file has not been changed.

cmd/appview/main.go

This file has not been changed.

History

14 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 success
expand
merge conflicts detected
expand
  • appview/pages/templates/user/login.html:33
  • appview/state/profile.go:817
  • appview/pages/templates/user/login.html:31
  • appview/pages/templates/user/login.html:93
  • appview/repo/artifact.go:251
  • appview/state/profile.go:528
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 failed
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{service,web}: service layer
1/3 failed, 2/3 timeout
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
1/3 failed, 1/3 timeout, 1/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview/service: service layer
3/3 success
expand
expand 0 comments
1 commit
expand
draft: appview: service layer
3/3 failed
expand
expand 0 comments
1 commit
expand
draft: appview: service layer
3/3 failed
expand
expand 0 comments