Skip to content

Commit

Permalink
Reformatted all files (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
zneix authored Dec 18, 2021
1 parent e3b0c40 commit 4429d7d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
)

type channelID struct {
ID string
ID string
chanType channelType
}

// Gets the channel type from a cache key type segment - used to identify what YouTube API to use
func getChannelTypeFromString(channelType string) channelType {
func getChannelTypeFromString(channelType string) channelType {
switch channelType {
case "c":
return CustomChannel
case "user":
return UserChannel
case "channel":
return IdentifierChannel
case "c":
return CustomChannel
case "user":
return UserChannel
case "channel":
return IdentifierChannel
}

return InvalidChannel
Expand All @@ -36,4 +36,3 @@ func deconstructChannelIDFromCacheKey(cacheKey string) channelID {

return channelID{ID: splitKey[1], chanType: getChannelTypeFromString(splitKey[0])}
}

28 changes: 14 additions & 14 deletions internal/resolvers/youtube/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ func loadChannels(channelCacheKey string, r *http.Request) (interface{}, time.Du
}

switch channelID.chanType {
case UserChannel:
builtRequest = builtRequest.ForUsername(channelID.ID)
case IdentifierChannel:
builtRequest = builtRequest.Id(channelID.ID)
case CustomChannel:
builtRequest = builtRequest.Id(channelID.ID)
case InvalidChannel:
return &resolver.Response{
Status: 500,
Message: "cached channel ID is invalid",
}, 1 * time.Hour, nil
case UserChannel:
builtRequest = builtRequest.ForUsername(channelID.ID)
case IdentifierChannel:
builtRequest = builtRequest.Id(channelID.ID)
case CustomChannel:
builtRequest = builtRequest.Id(channelID.ID)
case InvalidChannel:
return &resolver.Response{
Status: 500,
Message: "cached channel ID is invalid",
}, 1 * time.Hour, nil
}

youtubeResponse, err := builtRequest.Do()
Expand All @@ -130,10 +130,10 @@ func loadChannels(channelCacheKey string, r *http.Request) (interface{}, time.Du
channel := youtubeResponse.Items[0]

data := youtubeChannelTooltipData{
Title: channel.Snippet.Title,
Title: channel.Snippet.Title,
JoinedDate: humanize.CreationDateRFC3339(channel.Snippet.PublishedAt),
Subscribers: humanize.Number(channel.Statistics.SubscriberCount),
Views: humanize.Number(channel.Statistics.ViewCount),
Subscribers: humanize.Number(channel.Statistics.SubscriberCount),
Views: humanize.Number(channel.Statistics.ViewCount),
}

var tooltip bytes.Buffer
Expand Down
8 changes: 4 additions & 4 deletions internal/resolvers/youtube/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type youtubeVideoTooltipData struct {
}

type youtubeChannelTooltipData struct {
Title string
JoinedDate string
Subscribers string
Views string
Title string
JoinedDate string
Subscribers string
Views string
}
1 change: 1 addition & 0 deletions pkg/thumbnail/thumbnail_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package thumbnail
Expand Down
1 change: 1 addition & 0 deletions pkg/thumbnail/thumbnail_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package thumbnail
Expand Down
1 change: 1 addition & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

package tools
Expand Down

0 comments on commit 4429d7d

Please sign in to comment.