MCPcopy Create free account
hub / github.com/monitoror/monitoror / Checks

Method Checks

monitorables/github/api/usecase/github.go:66–96  ·  view source on GitHub ↗
(params *models.ChecksParams)

Source from the content-addressed store, hash-verified

64}
65
66func (gu *githubUsecase) Checks(params *models.ChecksParams) (*coreModels.Tile, error) {
67 tile := coreModels.NewTile(api.GithubChecksTileType).WithBuild()
68 tile.Label = params.Repository
69 tile.Build.Branch = pointer.ToString(git.HumanizeBranch(params.Ref))
70
71 // Request checks
72 checks, err := gu.repository.GetChecks(params.Owner, params.Repository, params.Ref)
73 if err != nil {
74 return nil, &coreModels.MonitororError{Err: err, Tile: tile, Message: "unable to load ref checks"}
75 }
76 if len(checks.Statuses) == 0 && len(checks.Runs) == 0 {
77 // Warning because request was correct but there is no build
78 return nil, &coreModels.MonitororError{Tile: tile, Message: "no ref checks found", ErrorStatus: coreModels.UnknownStatus}
79 }
80
81 // Compute checks into tile
82 gu.computeRefChecks(tile, checks, params.String())
83
84 // Author of last commit
85 if tile.Status == coreModels.FailedStatus && checks.HeadCommit != nil {
86 commit, err := gu.repository.GetCommit(params.Owner, params.Repository, *checks.HeadCommit)
87 if err == nil {
88 tile.Build.Author = &coreModels.Author{
89 Name: commit.Author.Name,
90 AvatarURL: commit.Author.AvatarURL,
91 }
92 }
93 }
94
95 return tile, nil
96}
97
98func (gu *githubUsecase) PullRequest(params *models.PullRequestParams) (*coreModels.Tile, error) {
99 tile := coreModels.NewTile(api.GithubPullRequestTileType).WithBuild()

Callers

nothing calls this directly

Calls 6

computeRefChecksMethod · 0.95
HumanizeBranchFunction · 0.92
WithBuildMethod · 0.80
GetChecksMethod · 0.65
GetCommitMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected