From 25ecbfc7d3aadbeed68c1aaa8e38f9c9ced16a7a Mon Sep 17 00:00:00 2001 From: Matt Gleich Date: Sat, 3 Aug 2024 00:10:14 -0400 Subject: [PATCH] chore(format): golines Signed-off-by: Matt Gleich --- internal/apis/github/github.go | 5 +++- internal/apis/steam/achievements.go | 22 ++++++++++++--- internal/apis/steam/games.go | 42 ++++++++++++++++++++--------- internal/apis/strava/event.go | 6 ++++- internal/apis/strava/map.go | 17 +++++++++--- internal/apis/strava/strava.go | 6 ++++- 6 files changed, 76 insertions(+), 22 deletions(-) diff --git a/internal/apis/github/github.go b/internal/apis/github/github.go index f7995b0..ac872d3 100644 --- a/internal/apis/github/github.go +++ b/internal/apis/github/github.go @@ -26,6 +26,9 @@ func Setup(router *chi.Mux) { githubCache := cache.NewCache("github", pinnedRepos) router.Get("/github/cache", githubCache.ServeHTTP()) - go githubCache.StartPeriodicUpdate(func() ([]repository, error) { return fetchPinnedRepos(githubClient) }, 2*time.Minute) + go githubCache.StartPeriodicUpdate( + func() ([]repository, error) { return fetchPinnedRepos(githubClient) }, + 2*time.Minute, + ) lumber.Success("setup github cache") } diff --git a/internal/apis/steam/achievements.go b/internal/apis/steam/achievements.go index 14a52aa..45d4c5c 100644 --- a/internal/apis/steam/achievements.go +++ b/internal/apis/steam/achievements.go @@ -52,7 +52,9 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) { "appid": {fmt.Sprint(appID)}, "format": {"json"}, } - resp, err := http.Get("https://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001?" + params.Encode()) + resp, err := http.Get( + "https://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001?" + params.Encode(), + ) if err != nil { lumber.Error(err, "sending request for player achievements from", appID, "failed") return nil, nil @@ -68,7 +70,12 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) { return nil, nil } if resp.StatusCode != http.StatusOK { - lumber.ErrorMsg(resp.StatusCode, "when trying to get player achievements for", appID, string(body)) + lumber.ErrorMsg( + resp.StatusCode, + "when trying to get player achievements for", + appID, + string(body), + ) return nil, nil } @@ -89,7 +96,9 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) { "appid": {fmt.Sprint(appID)}, "format": {"json"}, } - resp, err = http.Get("https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2?" + params.Encode()) + resp, err = http.Get( + "https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2?" + params.Encode(), + ) if err != nil { lumber.Error(err, "sending request for owned games failed") return nil, nil @@ -102,7 +111,12 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) { return nil, nil } if resp.StatusCode != http.StatusOK { - lumber.ErrorMsg(resp.StatusCode, "when trying to get player achievements for", appID, string(body)) + lumber.ErrorMsg( + resp.StatusCode, + "when trying to get player achievements for", + appID, + string(body), + ) return nil, nil } diff --git a/internal/apis/steam/games.go b/internal/apis/steam/games.go index 6e12a86..e40241d 100644 --- a/internal/apis/steam/games.go +++ b/internal/apis/steam/games.go @@ -47,7 +47,9 @@ func fetchRecentlyPlayedGames() ([]game, error) { "include_appinfo": {"true"}, "format": {"json"}, } - resp, err := http.Get("https://api.steampowered.com/IPlayerService/GetOwnedGames/v1?" + params.Encode()) + resp, err := http.Get( + "https://api.steampowered.com/IPlayerService/GetOwnedGames/v1?" + params.Encode(), + ) if err != nil { lumber.Error(err, "sending request for owned games failed") return nil, err @@ -79,7 +81,10 @@ func fetchRecentlyPlayedGames() ([]game, error) { var games []game for _, g := range ownedGames.Response.Games { - libraryURL := fmt.Sprintf("https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/library_600x900.jpg", g.AppID) + libraryURL := fmt.Sprintf( + "https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/library_600x900.jpg", + g.AppID, + ) libraryImageResponse, err := http.Get(libraryURL) if err != nil { lumber.Error(err, "getting library image for", g.Name, "failed") @@ -95,16 +100,29 @@ func fetchRecentlyPlayedGames() ([]game, error) { achievementPercentage, achievements := fetchGameAchievements(g.AppID) games = append(games, game{ - Name: g.Name, - AppID: g.AppID, - IconURL: fmt.Sprintf("https://media.steampowered.com/steamcommunity/public/images/apps/%d/%s.jpg", g.AppID, g.ImgIconURL), - RTimeLastPlayed: time.Unix(g.RTimeLastPlayed, 0), - PlaytimeForever: g.PlaytimeForever, - URL: fmt.Sprintf("https://store.steampowered.com/app/%d/", g.AppID), - HeaderURL: fmt.Sprintf("https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/header.jpg", g.AppID), - LibraryURL: libraryURLPtr, - LibraryHeroURL: fmt.Sprintf("https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/library_hero.jpg", g.AppID), - LibraryHeroLogoURL: fmt.Sprintf("https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/logo.png", g.AppID), + Name: g.Name, + AppID: g.AppID, + IconURL: fmt.Sprintf( + "https://media.steampowered.com/steamcommunity/public/images/apps/%d/%s.jpg", + g.AppID, + g.ImgIconURL, + ), + RTimeLastPlayed: time.Unix(g.RTimeLastPlayed, 0), + PlaytimeForever: g.PlaytimeForever, + URL: fmt.Sprintf("https://store.steampowered.com/app/%d/", g.AppID), + HeaderURL: fmt.Sprintf( + "https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/header.jpg", + g.AppID, + ), + LibraryURL: libraryURLPtr, + LibraryHeroURL: fmt.Sprintf( + "https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/library_hero.jpg", + g.AppID, + ), + LibraryHeroLogoURL: fmt.Sprintf( + "https://shared.akamai.steamstatic.com/store_item_assets/steam/apps/%d/logo.png", + g.AppID, + ), AchievementProgress: achievementPercentage, Achievements: achievements, }) diff --git a/internal/apis/strava/event.go b/internal/apis/strava/event.go index 9b78424..99df131 100644 --- a/internal/apis/strava/event.go +++ b/internal/apis/strava/event.go @@ -21,7 +21,11 @@ type event struct { Updates map[string]string `json:"updates"` } -func eventRoute(stravaCache *cache.Cache[[]activity], minioClient minio.Client, tokens tokens) http.HandlerFunc { +func eventRoute( + stravaCache *cache.Cache[[]activity], + minioClient minio.Client, + tokens tokens, +) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() body, err := io.ReadAll(r.Body) diff --git a/internal/apis/strava/map.go b/internal/apis/strava/map.go index 0575d82..c541f61 100644 --- a/internal/apis/strava/map.go +++ b/internal/apis/strava/map.go @@ -27,7 +27,11 @@ func fetchMap(polyline string) []byte { ) url := fmt.Sprintf( "https://api.mapbox.com/styles/v1/mattgleich/clxxsfdfm002401qj7jcxh47e/static/path-%f+%s(%s)/auto/%dx%d@2x?"+params.Encode(), - lineWidth, lineColor, url.QueryEscape(polyline), width, height, + lineWidth, + lineColor, + url.QueryEscape(polyline), + width, + height, ) resp, err := http.Get(url) if err != nil { @@ -73,7 +77,9 @@ func mapBlurData(data []byte) *string { lumber.Error(err, "creating png based off blurred image failed") return nil } - blurDataURI := "data:image/png;base64," + base64.StdEncoding.EncodeToString(blurImageBuffer.Bytes()) + blurDataURI := "data:image/png;base64," + base64.StdEncoding.EncodeToString( + blurImageBuffer.Bytes(), + ) return &blurDataURI } @@ -113,7 +119,12 @@ func removeOldMaps(minioClient minio.Client, activities []activity) { } } if !validObject { - err := minioClient.RemoveObject(context.Background(), bucketName, object.Key, minio.RemoveObjectOptions{}) + err := minioClient.RemoveObject( + context.Background(), + bucketName, + object.Key, + minio.RemoveObjectOptions{}, + ) if err != nil { lumber.Error(err, "failed to remove object") return diff --git a/internal/apis/strava/strava.go b/internal/apis/strava/strava.go index 3581ac1..193cec1 100644 --- a/internal/apis/strava/strava.go +++ b/internal/apis/strava/strava.go @@ -13,7 +13,11 @@ func Setup(router *chi.Mux) { stravaTokens := loadTokens() stravaTokens.refreshIfNeeded() minioClient, err := minio.New(secrets.SECRETS.MinioEndpoint, &minio.Options{ - Creds: credentials.NewStaticV4(secrets.SECRETS.MinioAccessKeyID, secrets.SECRETS.MinioSecretKey, ""), + Creds: credentials.NewStaticV4( + secrets.SECRETS.MinioAccessKeyID, + secrets.SECRETS.MinioSecretKey, + "", + ), Secure: true, }) if err != nil {