Created
July 25, 2017 16:50
-
-
Save jonasfranz/b9ba83380e785d9f5fd7cd035a4dace8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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