Skip to content

Commit ec9a4d7

Browse files
committed
chore[internal]: rename and cleanup functions
1 parent a170e3d commit ec9a4d7

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

internal/app/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func fetchGoalLinks(redditClient *reddit.Client, details *api.MatchDetails) tea.
370370
}
371371

372372
// Fetch links for all goals (uses cache internally)
373-
links := redditClient.GetGoalLinks(goals)
373+
links := redditClient.GoalLinks(goals)
374374

375375
return goalLinksMsg{matchID: details.ID, links: links}
376376
}

internal/app/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ func (m model) handleGoalLinks(msg goalLinksMsg) (tea.Model, tea.Cmd) {
989989
return m, nil
990990
}
991991

992-
// GetGoalReplayURL returns the replay URL for a goal if available.
992+
// GoalReplayURL returns the replay URL for a goal if available.
993993
// Returns empty string if no replay link is cached.
994-
func (m *model) GetGoalReplayURL(matchID, minute int) string {
994+
func (m *model) GoalReplayURL(matchID, minute int) string {
995995
if m.goalLinks == nil {
996996
return ""
997997
}

internal/data/settings.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ var DefaultLeagueIDs = []int{
157157
42, // UEFA Champions League
158158
}
159159

160-
// GetActiveLeagueIDs returns the league IDs that should be used for API calls.
160+
// ActiveLeagueIDs returns the league IDs that should be used for API calls.
161161
// If no leagues are selected in settings, returns the default leagues (not all).
162-
func GetActiveLeagueIDs() []int {
162+
func ActiveLeagueIDs() []int {
163163
settings, err := LoadSettings()
164164
if err != nil || len(settings.SelectedLeagues) == 0 {
165165
// Return default leagues for efficient API usage
@@ -169,8 +169,8 @@ func GetActiveLeagueIDs() []int {
169169
return settings.SelectedLeagues
170170
}
171171

172-
// GetAllLeagueIDs returns all supported league IDs (used as fallback).
173-
func GetAllLeagueIDs() []int {
172+
// AllLeagueIDs returns all supported league IDs (used as fallback).
173+
func AllLeagueIDs() []int {
174174
ids := make([]int, len(AllSupportedLeagues))
175175
for i, league := range AllSupportedLeagues {
176176
ids[i] = league.ID

internal/fotmob/cache.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func (c *ResponseCache) CachedMatchIDs() []int {
135135
return ids
136136
}
137137

138-
// ClearDetailsCache clears all cached match details.
139-
func (c *ResponseCache) ClearDetailsCache() {
138+
// ClearDetails clears all cached match details.
139+
func (c *ResponseCache) ClearDetails() {
140140
c.detailsMu.Lock()
141141
defer c.detailsMu.Unlock()
142142
c.detailsCache = make(map[int]cachedDetails)
@@ -172,9 +172,9 @@ func (c *ResponseCache) SetLiveMatches(matches []api.Match) {
172172
}
173173
}
174174

175-
// ClearLiveCache invalidates the live matches cache.
175+
// ClearLive invalidates the live matches cache.
176176
// Call this to force a refresh on next fetch.
177-
func (c *ResponseCache) ClearLiveCache() {
177+
func (c *ResponseCache) ClearLive() {
178178
c.liveMu.Lock()
179179
defer c.liveMu.Unlock()
180180
c.liveCache = nil

internal/fotmob/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ const (
1616
baseURL = "https://www.fotmob.com/api"
1717
)
1818

19-
// GetActiveLeagues returns the league IDs to use for API calls.
19+
// ActiveLeagues returns the league IDs to use for API calls.
2020
// This respects user settings - if specific leagues are selected, only those are returned.
2121
// If no selection is made, returns all supported leagues.
22-
func GetActiveLeagues() []int {
23-
return data.GetActiveLeagueIDs()
22+
func ActiveLeagues() []int {
23+
return data.ActiveLeagueIDs()
2424
}
2525

2626
// SupportedLeagues is kept for backward compatibility but now uses settings.
27-
// Use GetActiveLeagues() for dynamic league selection based on user preferences.
28-
var SupportedLeagues = data.GetAllLeagueIDs()
27+
// Use ActiveLeagues() for dynamic league selection based on user preferences.
28+
var SupportedLeagues = data.AllLeagueIDs()
2929

3030
// Client implements the api.Client interface for FotMob API
3131
type Client struct {
@@ -119,7 +119,7 @@ func (c *Client) MatchesByDateWithTabs(ctx context.Context, date time.Time, tabs
119119
var skippedFromCache int
120120

121121
// Get active leagues (respects user settings)
122-
activeLeagues := GetActiveLeagues()
122+
activeLeagues := ActiveLeagues()
123123

124124
// Query specified tabs
125125
for _, tab := range tabs {

internal/fotmob/live.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (c *Client) LiveMatches(ctx context.Context) ([]api.Match, error) {
4646
// LiveMatchesForceRefresh fetches live matches, bypassing the cache.
4747
// Use this for periodic refreshes to get the latest data.
4848
func (c *Client) LiveMatchesForceRefresh(ctx context.Context) ([]api.Match, error) {
49-
c.cache.ClearLiveCache()
49+
c.cache.ClearLive()
5050
return c.LiveMatches(ctx)
5151
}
5252

@@ -79,12 +79,12 @@ func (c *Client) LiveMatchesForLeague(ctx context.Context, leagueID int) ([]api.
7979

8080
// TotalLeagues returns the number of active leagues (respects user settings).
8181
func TotalLeagues() int {
82-
return len(GetActiveLeagues())
82+
return len(ActiveLeagues())
8383
}
8484

8585
// LeagueIDAtIndex returns the league ID at the given index from active leagues.
8686
func LeagueIDAtIndex(index int) int {
87-
activeLeagues := GetActiveLeagues()
87+
activeLeagues := ActiveLeagues()
8888
if index < 0 || index >= len(activeLeagues) {
8989
return 0
9090
}

internal/fotmob/stats.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// StatsData holds all matches data for the stats view.
12-
// This is returned by FetchStatsData and contains both finished and upcoming matches.
12+
// This is returned by StatsData and contains both finished and upcoming matches.
1313
type StatsData struct {
1414
// AllFinished contains finished matches for all fetched days (5 days by default)
1515
AllFinished []api.Match
@@ -23,7 +23,7 @@ type StatsData struct {
2323
// 5 days ensures we have data even during mid-week breaks.
2424
const StatsDataDays = 5
2525

26-
// FetchStatsData fetches all stats data in one call: 5 days of finished matches + today's upcoming.
26+
// StatsData fetches all stats data in one call: 5 days of finished matches + today's upcoming.
2727
// This is the primary API for the stats view - always fetches 5 days, then filters client-side.
2828
//
2929
// OPTIMIZATION: Only queries "fixtures" tab for today (upcoming matches).
@@ -38,7 +38,7 @@ const StatsDataDays = 5
3838
// - Single fetch pattern (always 5 days)
3939
// - Covers mid-week breaks when no matches scheduled
4040
// - Instant switching between Today/5d views after initial load
41-
func (c *Client) FetchStatsData(ctx context.Context) (*StatsData, error) {
41+
func (c *Client) StatsData(ctx context.Context) (*StatsData, error) {
4242
today := time.Now().UTC()
4343
todayStr := today.Format("2006-01-02")
4444

internal/reddit/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func (c *GoalLinkCache) Set(link GoalLink) error {
113113
return c.saveLocked()
114114
}
115115

116-
// GetAll returns all cached goal links for a match.
117-
func (c *GoalLinkCache) GetAll(matchID int) []GoalLink {
116+
// All returns all cached goal links for a match.
117+
func (c *GoalLinkCache) All(matchID int) []GoalLink {
118118
c.mu.RLock()
119119
defer c.mu.RUnlock()
120120

internal/reddit/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ func NewClientWithFetcher(fetcher Fetcher, cache *GoalLinkCache) *Client {
148148
}
149149
}
150150

151-
// GetGoalLink retrieves a cached goal link or fetches from Reddit if not cached.
151+
// GoalLink retrieves a cached goal link or fetches from Reddit if not cached.
152152
// Returns nil if the goal link was previously searched but not found.
153-
func (c *Client) GetGoalLink(goal GoalInfo) (*GoalLink, error) {
153+
func (c *Client) GoalLink(goal GoalInfo) (*GoalLink, error) {
154154
key := GoalLinkKey{MatchID: goal.MatchID, Minute: goal.Minute}
155155

156156
// Check cache first (includes "not found" markers)
@@ -186,9 +186,9 @@ const BatchSize = 5
186186
// BatchDelay is the delay between batches to avoid rate limiting.
187187
const BatchDelay = 2 * time.Second
188188

189-
// GetGoalLinks retrieves links for multiple goals, using cache where available.
189+
// GoalLinks retrieves links for multiple goals, using cache where available.
190190
// Goals are de-duplicated and batched to avoid rate limiting.
191-
func (c *Client) GetGoalLinks(goals []GoalInfo) map[GoalLinkKey]*GoalLink {
191+
func (c *Client) GoalLinks(goals []GoalInfo) map[GoalLinkKey]*GoalLink {
192192
results := make(map[GoalLinkKey]*GoalLink)
193193

194194
// De-duplicate goals by key and filter out already-cached goals
@@ -231,7 +231,7 @@ func (c *Client) GetGoalLinks(goals []GoalInfo) map[GoalLinkKey]*GoalLink {
231231

232232
for _, goal := range uncachedGoals[i:end] {
233233
key := GoalLinkKey{MatchID: goal.MatchID, Minute: goal.Minute}
234-
link, err := c.GetGoalLink(goal)
234+
link, err := c.GoalLink(goal)
235235
if err == nil && link != nil {
236236
results[key] = link
237237
}
@@ -261,14 +261,14 @@ func (c *Client) searchForGoal(goal GoalInfo) (*GoalLink, error) {
261261
}, nil
262262
}
263263
}
264-
264+
265265
// Strategy 1 didn't find a match, try broader searches
266266
// Only try one additional strategy to balance coverage vs rate limiting
267267
var allResults []SearchResult
268268
if err == nil {
269269
allResults = append(allResults, results1...)
270270
}
271-
271+
272272
// Strategy 2: Try with just the scoring team + minute
273273
// Determine which team scored
274274
scoringTeam := goal.AwayTeam
@@ -280,7 +280,7 @@ func (c *Client) searchForGoal(goal GoalInfo) (*GoalLink, error) {
280280
if err == nil {
281281
allResults = append(allResults, results2...)
282282
}
283-
283+
284284
// Remove duplicates based on URL
285285
seen := make(map[string]bool)
286286
uniqueResults := make([]SearchResult, 0, len(allResults))

scripts/test_fotmob_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func main() {
2525
defer cancel()
2626

2727
startTime := time.Now()
28-
statsData, err := client.FetchStatsData(ctx)
28+
statsData, err := client.StatsData(ctx)
2929
elapsed := time.Since(startTime)
3030

3131
if err != nil {

0 commit comments

Comments
 (0)