mirror of
https://github.com/taigrr/gico.git
synced 2026-04-01 18:58:59 -07:00
move types to types package
This commit is contained in:
@@ -2,6 +2,8 @@ package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
gterm "github.com/taigrr/gico/gitgraph/term"
|
||||
)
|
||||
|
||||
func NewDataSet() DataSet {
|
||||
@@ -9,10 +11,27 @@ func NewDataSet() DataSet {
|
||||
}
|
||||
|
||||
func NewCommit(Author, Message, Repo, Path string, LOC int) Commit {
|
||||
ci := Commit{
|
||||
return Commit{
|
||||
Message: Message,
|
||||
Author: Author, LOC: LOC, TimeStamp: time.Now(),
|
||||
Repo: Repo, Path: Path,
|
||||
}
|
||||
return ci
|
||||
}
|
||||
|
||||
func (yf YearFreq) String() string {
|
||||
return gterm.GetYearUnicode(yf)
|
||||
}
|
||||
|
||||
func (a YearFreq) Merge(b YearFreq) YearFreq {
|
||||
x := len(a)
|
||||
y := len(b)
|
||||
if x < y {
|
||||
x = y
|
||||
}
|
||||
c := make(YearFreq, x)
|
||||
copy(c, a)
|
||||
for i := 0; i < y; i++ {
|
||||
c[i] += b[i]
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Month string
|
||||
|
||||
type Commit struct {
|
||||
LOC int `json:"loc,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
TimeStamp time.Time `json:"ts,omitempty"`
|
||||
Author string `json:"author,omitempty"`
|
||||
Repo string `json:"repo,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
}
|
||||
|
||||
type DataSet map[time.Time]WorkDay
|
||||
|
||||
type WorkDay struct {
|
||||
Day time.Time `json:"day"`
|
||||
Count int `json:"count"`
|
||||
Commits []Commit `json:"commits,omitempty"`
|
||||
}
|
||||
type (
|
||||
Month string
|
||||
Commit struct {
|
||||
LOC int `json:"loc,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
TimeStamp time.Time `json:"ts,omitempty"`
|
||||
Author string `json:"author,omitempty"`
|
||||
Repo string `json:"repo,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
}
|
||||
DataSet map[time.Time]WorkDay
|
||||
YearFreq []int
|
||||
WorkDay struct {
|
||||
Day time.Time `json:"day"`
|
||||
Count int `json:"count"`
|
||||
Commits []Commit `json:"commits,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user