...
1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13
14 type Metric struct {
15 Name *string `json:"name"`
16 Key *string `json:"key"`
17 SPDXID *string `json:"spdx_id"`
18 URL *string `json:"url"`
19 HTMLURL *string `json:"html_url"`
20 NodeID *string `json:"node_id"`
21 }
22
23
24 type CommunityHealthFiles struct {
25 CodeOfConduct *Metric `json:"code_of_conduct"`
26 CodeOfConductFile *Metric `json:"code_of_conduct_file"`
27 Contributing *Metric `json:"contributing"`
28 IssueTemplate *Metric `json:"issue_template"`
29 PullRequestTemplate *Metric `json:"pull_request_template"`
30 License *Metric `json:"license"`
31 Readme *Metric `json:"readme"`
32 }
33
34
35 type CommunityHealthMetrics struct {
36 HealthPercentage *int `json:"health_percentage"`
37 Description *string `json:"description"`
38 Documentation *string `json:"documentation"`
39 Files *CommunityHealthFiles `json:"files"`
40 UpdatedAt *Timestamp `json:"updated_at"`
41 ContentReportsEnabled *bool `json:"content_reports_enabled"`
42 }
43
44
45
46
47 func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) {
48 u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo)
49 req, err := s.client.NewRequest("GET", u, nil)
50 if err != nil {
51 return nil, nil, err
52 }
53
54 metrics := &CommunityHealthMetrics{}
55 resp, err := s.client.Do(ctx, req, metrics)
56 if err != nil {
57 return nil, resp, err
58 }
59
60 return metrics, resp, nil
61 }
62
View as plain text