refactored code a bit
This commit is contained in:
parent
9b4db62b83
commit
25ca20c487
33
main.go
33
main.go
@ -46,33 +46,36 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// print out all rewards
|
||||
printRewards(rewards)
|
||||
}
|
||||
|
||||
func printRewards(rewards []lineEntry) {
|
||||
// daily
|
||||
listRewards("2006-01-02", rewards)
|
||||
daily := listRewards("2006-01-02", rewards)
|
||||
|
||||
// monthly
|
||||
listRewards("2006-01", rewards)
|
||||
monthly := listRewards("2006-01", rewards)
|
||||
|
||||
// yearly
|
||||
listRewards("2006", rewards)
|
||||
yearly := listRewards("2006", rewards)
|
||||
|
||||
// print rewards
|
||||
log.Println("listing daily Rewards")
|
||||
prettify.Print(daily)
|
||||
log.Println("listing monthly Rewards")
|
||||
prettify.Print(monthly)
|
||||
log.Println("listing yearly Rewards")
|
||||
prettify.Print(yearly)
|
||||
}
|
||||
|
||||
func listRewards(format string, entries []lineEntry) {
|
||||
var str string
|
||||
switch format {
|
||||
case "2006-01-02":
|
||||
str = "daily"
|
||||
case "2006-01":
|
||||
str = "monthly"
|
||||
case "2006":
|
||||
str = "yearly"
|
||||
}
|
||||
func listRewards(format string, entries []lineEntry) map[string]float64 {
|
||||
rewards := make(map[string]float64)
|
||||
log.Printf("listing %s Rewards", str)
|
||||
for i := range entries {
|
||||
rewardsString := entries[i].Time.Format(format)
|
||||
rewards[rewardsString] += entries[i].Amounts["DFI"]
|
||||
}
|
||||
prettify.Print(rewards)
|
||||
return rewards
|
||||
}
|
||||
|
||||
func readCSV(filename string) ([]byte, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user