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