Skip to content

Instantly share code, notes, and snippets.

@jonasfranz
Created July 25, 2017 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonasfranz/b9ba83380e785d9f5fd7cd035a4dace8 to your computer and use it in GitHub Desktop.
Save jonasfranz/b9ba83380e785d9f5fd7cd035a4dace8 to your computer and use it in GitHub Desktop.
package main
import (
"code.gitea.io/sdk/gitea"
"fmt"
)
func main() {
client := gitea.NewClient("http://localhost:3000", "YOUR_KEY")
times, err := client.GetMyTrackedTimes()
if err != nil {
panic(err)
}
totalTimeWorked := int64(0)
for _, t := range times {
totalTimeWorked += t.Time
}
fmt.Printf("Worked %v hours total :D", totalTimeWorked/(60*60))
if repos, err := client.ListMyRepos(); err == nil {
for _, repo := range repos {
fmt.Printf("Printing work @ %s/%s \n", repo.Owner.UserName, repo.Name)
if issues, err := client.ListRepoIssues(repo.Owner.UserName, repo.Name, gitea.ListIssueOption{}); err == nil {
for _, i := range issues {
fmt.Printf("Issue #%d \n", i.Index)
times, err := client.ListTrackedTimes(repo.Owner.UserName, repo.Name, i.Index)
if err != nil {
panic(err)
}
totalTimeWorked := int64(0)
for _, t := range times {
totalTimeWorked += t.Time
fmt.Printf("[%v]Worked %vh \n", t.Created, t.Time/(60*60))
}
fmt.Printf("Total: %vh \n", totalTimeWorked/(60*60))
}
}else {
fmt.Printf("Error: %v\n", err)
}
}
}else {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment