Skip to content

Commit

Permalink
chore(format): golines
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Aug 3, 2024
1 parent 7d5891b commit 25ecbfc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 22 deletions.
5 changes: 4 additions & 1 deletion internal/apis/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
22 changes: 18 additions & 4 deletions internal/apis/steam/achievements.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand All @@ -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
}

Expand Down
42 changes: 30 additions & 12 deletions internal/apis/steam/games.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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,
})
Expand Down
6 changes: 5 additions & 1 deletion internal/apis/strava/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions internal/apis/strava/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion internal/apis/strava/strava.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 25ecbfc

Please sign in to comment.