1
|
|
|
// Copyright 2018 Fedir RYKHTIK. All rights reserved. |
2
|
|
|
// Use of this source code is governed by the GNU GPL 3.0 |
3
|
|
|
// license that can be found in the LICENSE file. |
4
|
|
|
|
5
|
|
|
package main |
6
|
|
|
|
7
|
|
|
import ( |
8
|
|
|
"fmt" |
9
|
|
|
"time" |
10
|
|
|
|
11
|
|
|
"github.com/fedir/ghstat/github" |
12
|
|
|
) |
13
|
|
|
|
14
|
|
|
func repositoryData(rKey string, tmpFolder string, debug bool, dataChan chan Repository) { |
15
|
|
|
|
16
|
1 |
|
r := new(Repository) |
17
|
|
|
|
18
|
1 |
|
repositoryData := github.GetRepositoryStatistics(rKey, tmpFolder, debug) |
19
|
|
|
|
20
|
1 |
|
r.Name = repositoryData.FullName |
21
|
1 |
|
r.URL = fmt.Sprintf("https://github.com/%s", r.Name) |
22
|
1 |
|
r.Language = repositoryData.Language |
23
|
1 |
|
r.CreatedAt = repositoryData.CreatedAt |
24
|
1 |
|
r.Age = int(time.Since(repositoryData.CreatedAt).Seconds() / 86400) |
25
|
1 |
|
r.Watchers = repositoryData.Watchers |
26
|
1 |
|
r.Forks = repositoryData.Forks |
27
|
1 |
|
r.OpenIssues = repositoryData.OpenIssues |
28
|
1 |
|
r.License = "[Unknown]" |
29
|
1 |
|
if repositoryData.License.SPDXID != "" { |
30
|
1 |
|
r.License = repositoryData.License.SPDXID |
31
|
|
|
} |
32
|
1 |
|
r.Author = "[Unknown]" |
33
|
|
|
|
34
|
1 |
|
r.Author, |
35
|
|
|
r.LastCommitDate = github.GetRepositoryCommitsData(rKey, tmpFolder, debug) |
36
|
|
|
|
37
|
1 |
|
r.AuthorsFollowers = 0 |
38
|
1 |
|
if r.Author != "" { |
39
|
1 |
|
r.AuthorsFollowers = github.GetUserFollowers(r.Author, tmpFolder, debug) |
40
|
|
|
} else { |
41
|
1 |
|
r.Author = "[Account removed]" |
42
|
|
|
} |
43
|
|
|
|
44
|
1 |
|
r.ClosedIssues = 0 |
45
|
1 |
|
if repositoryData.HasIssues { |
46
|
1 |
|
r.ClosedIssues = github.GetRepositoryClosedIssues(rKey, tmpFolder, debug) |
47
|
|
|
} |
48
|
1 |
|
r.TotalIssues = r.OpenIssues + r.ClosedIssues |
49
|
1 |
|
r.Top10ContributorsFollowers, |
50
|
|
|
r.Contributors = github.GetRepositoryContributors(rKey, tmpFolder, debug) |
51
|
1 |
|
r.TotalTags = github.GetRepositoryTagsNumber(rKey, tmpFolder, debug) |
52
|
1 |
|
r.ActiveForkersPercentage = github.GetActiveForkersPercentage(r.Contributors, r.Forks) |
53
|
1 |
|
r.IssueByDay = github.GetIssueByDay(r.ClosedIssues+r.OpenIssues, r.Age) |
54
|
1 |
|
r.ClosedIssuesPercentage = github.GetClosedIssuesPercentage(repositoryData.OpenIssues, int(r.ClosedIssues)) |
55
|
|
|
|
56
|
1 |
|
contributionStatistics := github.GetContributionStatistics(rKey, tmpFolder, debug) |
57
|
1 |
|
r.TotalCommits = contributionStatistics.TotalCommits |
58
|
1 |
|
r.TotalAdditions = contributionStatistics.TotalAdditions |
59
|
1 |
|
r.TotalDeletions = contributionStatistics.TotalDeletions |
60
|
1 |
|
r.TotalCodeChanges = contributionStatistics.TotalCodeChanges |
61
|
1 |
|
r.MediCommitSize = contributionStatistics.MediumCommitSize |
62
|
|
|
|
63
|
1 |
|
r.CommitsByDay = github.GetCommitsByDay(contributionStatistics.TotalCommits, r.Age) |
64
|
|
|
|
65
|
1 |
|
dataChan <- *r |
66
|
|
|
} |
67
|
|
|
|