-
Notifications
You must be signed in to change notification settings - Fork 75
/
codetracker.go
59 lines (52 loc) · 2.11 KB
/
codetracker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2020 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package codetracker
// CodeTracker interface for getting Code Stats from a git based code tracking
// site (Github/Gitlab etc).
type CodeTracker interface {
// Update updates the code stats for a (organization, repos, start end date)
Update(repos []string, start, end int64)
// UserInfo returns pull request, review and commit information about
// a given user over a given start and stop time.
UserInfo(username string, start, end int) (*UserInformationResult, error)
}
// UserInformationResult models the data from the userinformation command.
type UserInformationResult struct {
User string `json:"user"`
MergedPRs []PullRequestInformation `json:"mergedprs"`
UpdatedPRs []PullRequestInformation `json:"updatedprs"`
Commits []CommitInformation `json:"commits"`
Reviews []ReviewInformation `json:"reviews"`
Year int `json:"year"`
Month int `json:"month"`
}
// PullRequestInformation contains all the specific details of pull request.
type PullRequestInformation struct {
Repository string `json:"repository"`
URL string `json:"url"`
Number int `json:"number"`
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
Date string `json:"date"`
State string `json:"state"`
}
// ReviewInformation contains all the details of a review of a pull request.
type ReviewInformation struct {
Repository string `json:"repository"`
URL string `json:"url"`
Number int `json:"number"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Date string `json:"date"`
State string `json:"state"`
}
// CommitInformation contains all the details of a review of a pull request.
type CommitInformation struct {
Repository string `json:"repository"`
URL string `json:"url"`
SHA string `json:"sha"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Date int64 `json:"date"`
}