Skip to content

Commit

Permalink
Merge branch 'master' of github.com:muety/wakapi
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Nov 4, 2024
2 parents 354c7f9 + d29b111 commit 7e976e6
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contributing
Please refer to our [contribution guidelines](https://github.com/muety/wakapi/wiki/Contributing) and [design goals](https://github.com/muety/wakapi/wiki/Design-Goals).
10 changes: 7 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"encoding/json"
"fmt"
"log"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -73,6 +72,7 @@ var emailProviders = []string{
// first wakatime commit was on this day ;-) so no real heartbeats should exist before
// https://github.com/wakatime/legacy-python-cli/commit/3da94756aa1903c1cca5035803e3f704e818c086
const heartbeatsMinDate = "2013-07-06"
const colorsFile = "data/colors.json"

var leaderboardScopes = []string{"24_hours", "week", "month", "year", "7_days", "14_days", "30_days", "6_months", "12_months", "all_time"}

Expand Down Expand Up @@ -437,7 +437,11 @@ func readColors() map[string]map[string]string {

raw := data.ColorsFile
if IsDev(env) {
raw, _ = os.ReadFile("data/colors.json")
if _, err := os.Stat(colorsFile); err == nil {
raw, _ = os.ReadFile(colorsFile)
} else {
Log().Warn("attempted to read colors from local fs in dev mode, but failed", "file", colorsFile)
}
}

var colors = make(map[string]map[string]string)
Expand Down Expand Up @@ -472,7 +476,7 @@ func Get() *Config {
func Load(configFlag string, version string) *Config {
config := &Config{}
if err := configor.New(&configor.Config{}).Load(config, configFlag); err != nil {
log.Fatal("failed to read config", err)
Log().Fatal("failed to read config", err)
}

env = config.Env
Expand Down
5 changes: 4 additions & 1 deletion config/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (
// ChooseFS returns a local (DirFS) file system when on 'dev' environment and the given go-embed file system otherwise
func ChooseFS(localDir string, embeddedFS fs.FS) fs.FS {
if Get().IsDev() {
return os.DirFS(localDir)
if _, err := os.Stat(localDir); err == nil {
return os.DirFS(localDir)
}
Log().Warn("attempted to use local fs for directory in dev mode, but failed", "path", localDir)
}
return embeddedFS
}
2 changes: 1 addition & 1 deletion config/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Log() *SentryLogger {
}

level := slog.LevelInfo
if Get().IsDev() {
if IsDev(env) {
level = slog.LevelDebug
}

Expand Down
8 changes: 4 additions & 4 deletions models/compat/wakatime/v1/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type StatsViewModel struct {
type StatsData struct {
Username string `json:"username"`
UserId string `json:"user_id"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Start string `json:"start"`
End string `json:"end"`
Status string `json:"status"`
TotalSeconds float64 `json:"total_seconds"`
DailyAverage float64 `json:"daily_average"`
Expand All @@ -45,8 +45,8 @@ func NewStatsFrom(summary *models.Summary, filters *models.Filters) *StatsViewMo
data := &StatsData{
Username: summary.UserID,
UserId: summary.UserID,
Start: summary.FromTime.T(),
End: summary.ToTime.T(),
Start: summary.FromTime.T().Format(time.RFC3339),
End: summary.ToTime.T().Format(time.RFC3339),
Status: "ok",
TotalSeconds: totalTime.Seconds(),
DaysIncludingHolidays: numDays,
Expand Down
2 changes: 1 addition & 1 deletion static/assets/css/app.dist.css

Large diffs are not rendered by default.

Binary file modified static/assets/css/app.dist.css.br
Binary file not shown.
16 changes: 9 additions & 7 deletions views/summary.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,34 @@

{{ if not .IsProjectDetails }}
<!-- KPIs -->
<div class="w-full mb-4 grid grid-cols-2 sm:grid-cols-2 md:grid-cols-4 gap-2">
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="w-full mb-4 grid grid-cols-2 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-2">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Total Time</span>
<span class="font-semibold text-xl truncate" title="{{ .TotalTime | duration }}">{{ .TotalTime | duration }}</span>
<span class="text-xs text-gray-500" title="(your oldest heartbeat in selected range)" style="margin-bottom: -8px">after {{ .FromTime.T | datetime }}</span>
</div>
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Total Heartbeats</span>
<span class="font-semibold text-xl truncate" title="{{ .NumHeartbeats }}">{{ .NumHeartbeats }}</span>
</div>
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Top Project</span>
<span class="font-semibold text-xl truncate" title="{{ .MaxByToString 0 }}">{{ .MaxByToString 0 }}</span>
</div>
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Top Language</span>
<span class="font-semibold text-xl truncate" title="{{ .MaxByToString 1 }}">{{ .MaxByToString 1 }}</span>
</div>
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Top OS</span>
<span class="font-semibold text-xl truncate" title="{{ .MaxByToString 3 }}">{{ .MaxByToString 3 }}</span>
</div>
<div class="flex flex-col w-full p-4 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<div class="flex flex-col w-full p-4 pt-2 rounded-md text-gray-300 bg-gray-850 leading-none border-2 border-green-700">
<span class="text-xs text-gray-500 font-semibold">Top Editor</span>
<span class="font-semibold text-xl truncate" title="{{ .MaxByToString 2 }}">{{ .MaxByToString 2 }}</span>
</div>
</div>

{{ else }}
<div class="mb-8 w-full">
<h1 class="font-semibold text-3xl text-white">
Expand Down

0 comments on commit 7e976e6

Please sign in to comment.