DRAW
cicd / ci (push) Failing after 23s
Details
cicd / ci (push) Failing after 23s
Details
parent
19f4b614d3
commit
e581b7835c
|
|
@ -49,20 +49,42 @@ func (period *Period) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (period *Period) Set(s string) error {
|
func (period *Period) Set(s string) error {
|
||||||
|
ss := strings.Split(s, "..")
|
||||||
|
if err := period.setStartStop(ss[0]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ss) != 2 {
|
||||||
|
} else if err := period.setStop(ss[1]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (period *Period) setStartStop(s string) error {
|
||||||
|
stop, err := period.setT(s, &period.Start)
|
||||||
|
period.Stop = stop
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (period *Period) setStop(s string) error {
|
||||||
|
_, err := period.setT(s, &period.Stop)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Period) setT(s string, t *time.Time) (time.Time, error) {
|
||||||
if result, err := time.Parse("2006", s); err == nil {
|
if result, err := time.Parse("2006", s); err == nil {
|
||||||
period.Start = result
|
*t = result
|
||||||
period.Stop = result.AddDate(1, 0, 0).Add(-1 * time.Minute)
|
return result.AddDate(1, 0, 0).Add(-1 * time.Minute), nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
if result, err := time.Parse("2006-01", s); err == nil {
|
if result, err := time.Parse("2006-01", s); err == nil {
|
||||||
period.Start = result
|
*t = result
|
||||||
period.Stop = result.AddDate(0, 1, 0).Add(-1 * time.Minute)
|
return result.AddDate(0, 1, 0).Add(-1 * time.Minute), nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
if result, err := time.Parse("2006-01-02", s); err == nil {
|
if result, err := time.Parse("2006-01-02", s); err == nil {
|
||||||
period.Start = result
|
*t = result
|
||||||
period.Stop = result.AddDate(0, 0, 1).Add(-1 * time.Minute)
|
return result.AddDate(0, 0, 1).Add(-1 * time.Minute), nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unimplemented format: %s", s)
|
return time.Time{}, fmt.Errorf("unimplemented format: %s", s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ func Main() {
|
||||||
|
|
||||||
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||||
fs.Var(&config.Files, "f", "paths to files")
|
fs.Var(&config.Files, "f", "paths to files")
|
||||||
fs.Var(&config.Query.Period, "period", "period")
|
fs.Var(&config.Query.Period, "period", "period can be YYYY, YYYY-mm, YYYY-mm-dd, x..y")
|
||||||
fs.StringVar(&config.Query.Sort, "S", "", "sort ie date")
|
fs.StringVar(&config.Query.Sort, "S", "", "sort ie date")
|
||||||
fs.BoolVar(&config.Query.NoRounding, "no-rounding", false, "no rounding")
|
fs.BoolVar(&config.Query.NoRounding, "no-rounding", false, "no rounding")
|
||||||
fs.BoolVar(&config.Compact, "c", false, "reg entries oneline")
|
fs.BoolVar(&config.Compact, "c", false, "reg entries oneline")
|
||||||
|
|
@ -139,7 +139,22 @@ func Main() {
|
||||||
Normalize(cpiNormalizer, "9")
|
Normalize(cpiNormalizer, "9")
|
||||||
FPrintBalances(w, "", balances, nil, config.Query.USDOnly, config.Query.Normalize, time.Now().Format("2006-01-02"), false, maxAccW)
|
FPrintBalances(w, "", balances, nil, config.Query.USDOnly, config.Query.Normalize, time.Now().Format("2006-01-02"), false, maxAccW)
|
||||||
case "gra":
|
case "gra":
|
||||||
deltas = deltas.Group(ledger.GroupDate("^[0-9]{4}-[0-9]{2}"))
|
dateGrouping := "^[0-9]{4}-[0-9]{2}"
|
||||||
|
if period := config.Query.Period; !period.Empty() {
|
||||||
|
day := time.Hour * 24
|
||||||
|
year := day * 365
|
||||||
|
r := period.Stop.Sub(period.Start)
|
||||||
|
if r > 10*year {
|
||||||
|
dateGrouping = "^[0-9]{4}"
|
||||||
|
} else if r > 5*year {
|
||||||
|
} else if r > year {
|
||||||
|
dateGrouping = "^[0-9]{4}-[0-9]{2}-[0-9]"
|
||||||
|
} else {
|
||||||
|
dateGrouping = "^[0-9]{4}-[0-9]{2}-[0-9]{2}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deltas = deltas.Group(ledger.GroupDate(dateGrouping))
|
||||||
|
|
||||||
transactions := deltas.Transactions()
|
transactions := deltas.Transactions()
|
||||||
cumulative := make(ledger.Balances)
|
cumulative := make(ledger.Balances)
|
||||||
data := map[string][]float64{}
|
data := map[string][]float64{}
|
||||||
|
|
@ -185,23 +200,9 @@ func Main() {
|
||||||
for _, k := range labels {
|
for _, k := range labels {
|
||||||
points = append(points, data[k])
|
points = append(points, data[k])
|
||||||
}
|
}
|
||||||
|
for i := range points {
|
||||||
pointsMax := func() float64 {
|
for j := range points[i] {
|
||||||
var max float64
|
points[i][j] /= 1000.0
|
||||||
for _, vs := range points {
|
|
||||||
for _, v := range vs {
|
|
||||||
if max < v {
|
|
||||||
max = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return max
|
|
||||||
}
|
|
||||||
for pointsMax() > 100 {
|
|
||||||
for i := range points {
|
|
||||||
for j := range points[i] {
|
|
||||||
points[i][j] /= 10.0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue