diff --git a/README.md b/README.md index 22e7b6b..cde1304 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ ![](https://img.shields.io/github/license/muety/wakapi?style=flat-square) [![Go Report Card](https://goreportcard.com/badge/github.com/muety/wakapi?style=flat-square)](https://goreportcard.com/report/github.com/muety/wakapi) -[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoff.ee/n1try) - --- **A minimalist, self-hosted WakaTime-compatible backend for coding statistics** diff --git a/models/compat/v1/summaries.go b/models/compat/v1/summaries.go index 4a2a280..2650080 100644 --- a/models/compat/v1/summaries.go +++ b/models/compat/v1/summaries.go @@ -5,6 +5,7 @@ import ( "github.com/muety/wakapi/models" "github.com/muety/wakapi/utils" "math" + "sync" "time" ) @@ -107,22 +108,46 @@ func newDataFrom(s *models.Summary) *wakatimeSummariesData { }, } - for i, e := range s.Projects { - data.Projects[i] = convertEntry(e, s.TotalTimeBy(models.SummaryProject)) - } - for i, e := range s.Editors { - data.Editors[i] = convertEntry(e, s.TotalTimeBy(models.SummaryEditor)) - } - for i, e := range s.Languages { - data.Languages[i] = convertEntry(e, s.TotalTimeBy(models.SummaryLanguage)) - } - for i, e := range s.OperatingSystems { - data.OperatingSystems[i] = convertEntry(e, s.TotalTimeBy(models.SummaryOS)) - } - for i, e := range s.Machines { - data.Machines[i] = convertEntry(e, s.TotalTimeBy(models.SummaryMachine)) - } + var wg sync.WaitGroup + wg.Add(5) + go func(data *wakatimeSummariesData) { + defer wg.Done() + for i, e := range s.Projects { + data.Projects[i] = convertEntry(e, s.TotalTimeBy(models.SummaryProject)) + } + }(data) + + go func(data *wakatimeSummariesData) { + defer wg.Done() + for i, e := range s.Editors { + data.Editors[i] = convertEntry(e, s.TotalTimeBy(models.SummaryEditor)) + } + }(data) + + go func(data *wakatimeSummariesData) { + defer wg.Done() + for i, e := range s.Languages { + data.Languages[i] = convertEntry(e, s.TotalTimeBy(models.SummaryLanguage)) + + } + }(data) + + go func(data *wakatimeSummariesData) { + defer wg.Done() + for i, e := range s.OperatingSystems { + data.OperatingSystems[i] = convertEntry(e, s.TotalTimeBy(models.SummaryOS)) + } + }(data) + + go func(data *wakatimeSummariesData) { + defer wg.Done() + for i, e := range s.Machines { + data.Machines[i] = convertEntry(e, s.TotalTimeBy(models.SummaryMachine)) + } + }(data) + + wg.Wait() return data } diff --git a/routes/compat/v1/summaries.go b/routes/compat/v1/summaries.go index 7a69fef..90f2134 100644 --- a/routes/compat/v1/summaries.go +++ b/routes/compat/v1/summaries.go @@ -25,7 +25,7 @@ func NewCompatV1SummariesHandler(summaryService *services.SummaryService) *Compa } /* -TODO: support parameters: branches, timeout, writes_only, timezone +TODO: support parameters: project, branches, timeout, writes_only, timezone https://wakatime.com/developers#summaries timezone can be specified via an offset suffix (e.g. +02:00) in date strings */ diff --git a/version.txt b/version.txt index e33692a..70ad429 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.10.1 \ No newline at end of file +1.10.2 \ No newline at end of file