diff --git a/api/handler.go b/api/handler.go index bd5f715..e827a7e 100644 --- a/api/handler.go +++ b/api/handler.go @@ -9,7 +9,7 @@ import ( ) func MountainHandler() ([]byte, error) { - username := os.Getenv("USERNAME") + username := os.Getenv("USERNAME2") if len(username) == 0 { return nil, errors.New("USERNAME is not set") } @@ -32,17 +32,9 @@ func MountainHandler() ([]byte, error) { endOfMonth := toDate.Day() dailyCommitsMonthCount := dailyCommitsPeriodCount(user.DailyCommitsPeriod) + commitsMonthCount := commitsPeriodCount(user.DailyCommitsPeriod) - fromDate = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.UTC) - toDate = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 999999999, time.UTC) - user, err = getUserData(username, fromDate, toDate) - if err != nil { - return nil, err - } - - commitsYearCount := commitsPeriodCount(user.DailyCommitsPeriod) - - svg := ui.GenerateCard(username, dailyCommitsSince1MonthCount, dailyCommitsMonthCount, endOfMonth, commitsYearCount) + svg := ui.GenerateCard(username, dailyCommitsSince1MonthCount, dailyCommitsMonthCount, endOfMonth, commitsMonthCount) return []byte(svg), nil } diff --git a/ui/card.go b/ui/card.go index cc7386d..b3041b4 100644 --- a/ui/card.go +++ b/ui/card.go @@ -22,23 +22,22 @@ func title(mountainIcon, textColor, username string) string { `, mountainIcon, textColor, username) } -func leftInfo(dailyCommitsMonthCount, endOfMonth int, treeIcon, climberIcon, textColor, formatCommitsYearCount string) string { +func leftInfo(dailyCommitsMonthCount, endOfMonth int, treeIcon, climberIcon, textColor, formatCommitsMonthCount string) string { return fmt.Sprintf(` %s - Commit Day - Per Month - %d/%d + Commit Day + Per Month + %d/%d - %s Total Commits - (2024) - %s - + %s Month + Commit + %s - `, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, formatCommitsYearCount) + `, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, formatCommitsMonthCount) } func rightInfo(bgColor, borderColor, grass string) string { @@ -56,7 +55,7 @@ func endSVG() string { return `` } -func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMonthCount, endOfMonth, commitsYearCount int) string { +func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMonthCount, endOfMonth, commitsMonthCount int) string { themeName := os.Getenv("THEME") theme := getTheme(themeName) @@ -64,12 +63,12 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon climberIcon := changeIconColor(Climber, theme.IconColor) treeIcon := changeIconColor(Tree, theme.IconColor) grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name, theme.TriangleMountainColor) - formatCommitsYearCount := formatNumber(commitsYearCount) + formatCommitsMonthCount := formatNumber(commitsMonthCount) svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) svg += title(mountainIcon, theme.TitleColor, username) - svg += leftInfo(dailyCommitsMonthCount, endOfMonth, treeIcon, climberIcon, theme.TextColor, formatCommitsYearCount) + svg += leftInfo(dailyCommitsMonthCount, endOfMonth, treeIcon, climberIcon, theme.TextColor, formatCommitsMonthCount) svg += rightInfo(theme.BgColor, theme.BorderColor, grassMountain) svg += endSVG()