Repository navigation
Expand file tree
/
Copy pathtypes.go
More file actions
550 lines (492 loc) · 17.6 KB
/
Copy pathtypes.go
File metadata and controls
550 lines (492 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
// ABOUTME: Type definitions for SleeperPy application
// ABOUTME: Includes data structures for players, leagues, transactions, and caching
package main
import (
"sync"
"time"
)
// Cache for Boris Chen tiers with TTL
type tiersCache struct {
sync.RWMutex
data map[string]map[string][][]string
timestamp map[string]time.Time
ttl time.Duration
}
// Dynasty value data structure
type DynastyValue struct {
Name string
Position string
Value1QB int // blended across available sources
Value2QB int
ScrapeDate string
// Per-source breakdown, used to flag agreement/disagreement between
// sources rather than presenting one blended number as gospel.
DynastyProcessValue1QB int
DynastyProcessValue2QB int
FantasyCalcValue1QB int
FantasyCalcValue2QB int
// DynastyADPValue is derived from live FantasyFootballCalculator dynasty
// startup-draft ADP (decay-scaled to roughly the same 0-9999 range as
// the other sources). FFC doesn't publish a superflex-specific dynasty
// ADP, so this single figure is blended into both Value1QB and Value2QB.
DynastyADPValue int
}
// Cache for dynasty values
type dynastyCache struct {
sync.RWMutex
data map[string]DynastyValue // key: normalized player name
timestamp time.Time
ttl time.Duration
}
// Cache for Sleeper trending add/drop data, keyed by trend type ("add"/"drop")
type trendingCache struct {
sync.RWMutex
data map[string]map[string]int // trend type -> player_id -> count
timestamp map[string]time.Time
ttl time.Duration
}
// Cache for the combined cross-position draft kit tiers, keyed by
// "scoring:adjust" (e.g. "PPR:0")
type draftKitTierCache struct {
sync.RWMutex
data map[string][][]string
timestamp map[string]time.Time
ttl time.Duration
}
// Cache for weekly player projections, keyed by "season:week" (e.g. "2026:1")
type projectionsCache struct {
sync.RWMutex
data map[string]map[string]interface{}
timestamp map[string]time.Time
ttl time.Duration
}
// Cache for NFL bye weeks, keyed by season year
type byeWeekCache struct {
sync.RWMutex
data map[int]map[string]int // year -> team abbreviation -> bye week number
timestamp map[int]time.Time
ttl time.Duration
}
// Cache for Sleeper players API response
type playersCache struct {
sync.RWMutex
data map[string]interface{}
timestamp time.Time
ttl time.Duration
}
type PlayerRow struct {
Pos string
Name string
Tier interface{}
IsTierWorseThanBench bool
ShouldSwapIn bool
IsFreeAgent bool
IsUpgrade bool
UpgradeFor string // Name of player this FA is better than
UpgradeType string // "Starter" or "Bench" or ""
UpgradeValueDiff int // Dynasty value gained by making this add/drop swap (only set alongside UpgradeFor)
IsFlex bool // Heuristic FLEX indicator
IsSuperflex bool // Heuristic SUPERFLEX indicator
FlexTier int // Tier from the FLX table, for RB/WR/TE only (0 if not flex-eligible or unranked). Only comparable to other FlexTier values -- never to a positional Tier.
DynastyValue int // Blended dynasty value (DynastyProcess + FantasyCalc average)
DynastyValueLowConf bool // True when the two dynasty value sources disagree by 30%+
Age int // Player age from Sleeper API
RosterPercent float64
Team string // NFL team abbreviation
InjuryStatus string // "Out", "Doubtful", "Questionable", "IR", etc. (empty if healthy)
DepthChartOrder int // Sleeper's depth chart rank at this position on this team (0 if unknown)
OnBye bool // True if Team has a bye this week
ADPTier int // Secondary tier from live ADP draft-market data (0 = not computed/not found). Only populated when TierSource setting is "both".
ProjectedPoints float64 // Weekly projected fantasy points (0 = not found/not yet published by Sleeper)
IsTaxiSquad bool // True if this player is currently stashed on the user's taxi squad -- excluded from drop/cut value comparisons since taxi stashes are intentionally low-value prospects, not roster mistakes
IsTaxiEligible bool // True if a free agent's NFL experience is within the league's taxi eligibility window (see LeagueData.TaxiYears)
YearsExp int // Player's NFL experience in years, from Sleeper (0 = rookie)
}
// LowestValuePlayer pairs one of the user's weakest dynasty assets at a
// position with the best unowned player at that same position, for a quick
// "should I even keep this guy" comparison.
type LowestValuePlayer struct {
YourPlayer PlayerRow
BestAvailable PlayerRow // zero-value (Name == "") if no valued free agent exists at this position
ValueGap int // BestAvailable.DynastyValue - YourPlayer.DynastyValue (only meaningful when BestAvailable is set)
}
// TaxiSuggestion recommends stashing a taxi-eligible free agent on an open
// taxi slot, or -- once taxi slots are full -- swapping out the weakest
// current taxi stash for a clearly better prospect.
type TaxiSuggestion struct {
Prospect PlayerRow // Taxi-eligible free agent to add
HasOpenSlot bool // True if this can go straight into an unused taxi slot
DropFromTaxi PlayerRow // Current taxi squad player to drop instead (zero-value if HasOpenSlot)
}
// LeagueChampion is one past season's title winner, resolved from Sleeper's
// winners_bracket for that season's league_id.
type LeagueChampion struct {
Season string
TeamName string
OwnerName string
OwnerID string
IsUserTeam bool
}
type TeamAgeData struct {
TeamName string
OwnerName string
AvgAge float64
Wins int // Real season wins, from roster settings
Losses int // Real season losses, from roster settings
Rank int // Standings position (1 = best record) -- computed from Wins/Losses, not a raw count
RosterID int
IsUserTeam bool
RosterValue int // Total dynasty value of every rostered player (bench included)
StarterValue int // Dynasty value of the best lineup the roster can field under the league's slot counts
Strategy string // "Win Now", "Contending", "Rebuilding" -- set from calculatePowerRankings, kept in sync so this table and Power Rankings never disagree
}
type PowerRanking struct {
Rank int
TeamName string
RosterID int
RosterValue int
StarterValue int
Wins int
Losses int
AvgAge float64
Strategy string // "Win Now", "Contending", "Rebuilding"
IsUserTeam bool
ValueRank int // Rank by starter value
StandingRank int // Rank by wins
}
type DraftPick struct {
Round int
Year int
OwnerName string // "You" or team name
OriginalName string // Original owner if traded, empty if not traded
RosterID int
IsYours bool
}
type ProjectedDraftPick struct {
Year int
Round int
OverallPick int // Projected overall pick number (e.g., 1.01 = 1, 1.12 = 12, 2.01 = 13)
ProjectedPosition int // Projected position within round (1-12)
OwnerName string // Team that currently owns this pick
OriginalOwner string // Original owner if traded
CurrentStanding int // Current standing of the team (1 = worst record, 12 = best)
TeamRecord string // e.g., "3-11"
IsYours bool
}
type PositionalKTC struct {
QB int
RB int
WR int
TE int
}
type TradeTarget struct {
TeamName string
Reason string
YourSurplus string
TheirSurplus string
Proposal *TradeProposal // Feature #9: Trade coach proposal
}
type TradeProposal struct {
TargetTeamName string
YourOffer []ProposalPlayer
TheirReturn []ProposalPlayer
ValueDelta int
Fairness string
Rationale string
RiskLevel string
WinNowImpact int
FutureImpact int
}
type ProposalPlayer struct {
Name string
Position string
DynastyValue int
Tier string
}
type PlayerNews struct {
PlayerName string
Position string
NewsText string
Source string
Timestamp time.Time
InjuryStatus string
InjuryBodyPart string
InjuryNotes string
IsStarter bool
DynastyValue int
ImportanceScore int // Feature #4: 0-200 range for news prioritization
}
type CompressedNews struct {
TimeWindow string // "This Week" or "Last 3 Months"
TopHeadlines []PlayerNews // Max 3 items
TotalItems int // Total news items for user's players
}
type ContextCard struct {
Title string // "Age Rank", "Value Rank", etc.
Value string // "3rd youngest", "8,450 (#2)"
Trend string // "↗ Getting younger", "→ Stable", etc.
Icon string // Single emoji for visual scanning
Color string // Color code for styling
}
type ValueChange struct {
PlayerName string
Position string
OldValue int
NewValue int
Delta int
DeltaPct float64
IsRiser bool
IsOwned bool // User owns this player
}
type TradeFairness struct {
Winner string // "TeamA" or "TeamB" or "Fair"
ValueDelta int // Absolute KTC difference
ValueDeltaPct float64 // % of smaller team's roster value
Fleeced bool // Extreme gap flag
Context string // "Competing strategy", "Rebuilding", "Extreme value gap"
WinnerTeam string // Team that got better value
DisplayBadge string // "🟢 +12%", "🔴 FLEECED", "→ Fair"
}
type TradeRetrospective struct {
Winner string // Who won the trade overall
ValueSwing int // How much value swung
DaysElapsed int // Days since trade
WinnerGain string // "+500 value" or similar
}
type Transaction struct {
Type string // "trade", "waiver", "free_agent"
LeagueID string
Timestamp time.Time
Description string
TeamNames []string
PlayerNames []string
Team1 string
Team2 string
Team1Gave []string
Team2Gave []string
Team1GaveValue int // Total dynasty value of Team1's players
Team2GaveValue int // Total dynasty value of Team2's players
NetValue int // Net value difference (positive = Team1 gained value)
AddedPlayer string
DroppedPlayer string
Fairness TradeFairness // Feature #3: Trade fairness detection
Retrospective TradeRetrospective // Feature #5: Trade retrospective analysis
}
type RookieProspect struct {
Name string
Position string
College string
Value int
Rank int
}
type LeagueTrends struct {
MostActiveTeams []TeamActivity
HotWaiverPlayers []WaiverActivity
TradeVolume int
WaiverVolume int
PositionScarcity map[string]int // Position -> number of available players
}
type TeamActivity struct {
TeamName string
Transactions int
Trades int
WaiverClaims int
ActivityLevel string // "Very Active", "Active", "Quiet"
}
type WaiverActivity struct {
PlayerName string
Position string
ClaimCount int
LastClaimed string // Time ago
}
type Action struct {
Priority int // 1-5 (1 = highest)
Category string // "swap", "waiver", "trade", "injury", "lineup"
Title string // "Swap Starter"
Description string // "Start Jahmyr Gibbs over James Conner"
Impact string // "+1.2 tier upgrade"
Link string // "#player-name" anchor link
Completed bool // User checked it off
WeekID string // "2026-W14" for persistence
// Set only when an action is aggregated across leagues (dashboard feed).
// Empty on the per-league tiers page since the league is already the context.
LeagueID string
LeagueName string
}
type WaiverRecommendation struct {
Player PlayerRow
Score int
Priority string
SuggestedBid int
Rationale string
ImpactType string
Role string
UsageSignal string
TierDelta float64
PositionScarcity int
}
type SeasonPlan struct {
CurrentPhase string
PhaseDescription string
Strategy string
ScheduleDifficulty string
ScheduleNote string
KeyDates []KeyDate
Recommendations []string
TradeWindow string
NextMilestone string
WeeksRemaining int
}
type KeyDate struct {
Date time.Time
Label string
DaysAway int
Importance string
ActionItems []string
}
type DraftStrategy struct {
OverallApproach string
Needs []RookieDraftNeed
PickInventory string
CapitalLevel string
Recommendations []string
}
type RookieDraftNeed struct {
Position string
Priority int
Reasoning string
TargetArchetype string
DraftRange string
PicksAvailable int
Examples []string
}
type LeagueData struct {
LeagueID string
LeagueName string
Season string
Scoring string
IsDynasty bool
HasMatchups bool
DynastyValueDate string
LeagueSize int
RosterSlots string
Starters []PlayerRow
Unranked []PlayerRow
AvgTier string
AvgOppTier string
WinProb string
Bench []PlayerRow
BenchUnranked []PlayerRow
FreeAgentsByPos map[string][]PlayerRow
TopFreeAgents []PlayerRow
TopFreeAgentsByValue []PlayerRow
AllFreeAgentsByValue []PlayerRow // Every unowned skill-position player with a dynasty value, ranked highest first (dynasty add/drop finder)
HasTaxiSquad bool // True if the league has taxi_slots configured
TaxiYears int // Max NFL experience (years) for taxi eligibility -- from league settings, defaults to 1 (rookies/1st-year players only)
OpenTaxiSlots int // Unused taxi slots on the user's roster right now
TaxiSuggestions []TaxiSuggestion // Best taxi-eligible free agents to stash, given open slots / current taxi squad
LowestValueRoster []LowestValuePlayer // User's 3 weakest dynasty assets vs. the best available replacement at each position
TotalRosterValue int
UserAvgAge float64
TeamAges []TeamAgeData
PowerRankings []PowerRanking
LeagueHistory []LeagueChampion // Past seasons' champions, most recent first
DraftPicks []DraftPick
ProjectedDraftPicks []ProjectedDraftPick
TradeTargets []TradeTarget
PositionalBreakdown PositionalKTC
PlayerNewsFeed []PlayerNews
BreakoutCandidates []PlayerRow
CutCandidates []PlayerRow
AgingPlayers []PlayerRow
RecentTransactions []Transaction
TopRookies []RookieProspect
LeagueTrends LeagueTrends
TeamTalk string // AI-generated team talk (only set if OPENROUTER_API_KEY is configured)
WeeklyActions []Action // Feature #2: Weekly Action List
CompressedNews CompressedNews // Feature #4: News Signal Compression
ContextCards []ContextCard // Feature #6: League Context Cards
ValueChanges []ValueChange // Feature #7: Value Change Tracker
WaiverRecommendations []WaiverRecommendation // Feature #10: Advanced Waiver Model
SeasonPlan SeasonPlan // Feature #11: Season Planner
DraftStrategy DraftStrategy // Feature #12: Rookie Draft Needs
}
type TiersPage struct {
Error string
Leagues []LeagueData
Username string
AIEnabled bool // true if OPENROUTER_API_KEY is configured
AIOverview string // AI-generated all-teams overview, if requested
IsOffseason bool // more than a week out from the regular season start
}
type DraftKitPlayer struct {
Name string
Position string // "" if the player couldn't be matched in the Sleeper players list
}
type DraftKitTier struct {
Number int
Players []DraftKitPlayer
}
type DraftKitPage struct {
Username string
Scoring string // "PPR", "Half PPR", "Standard"
Adjust int // 0, 1, or 2 -- Boris Chen's 3 unlabeled variants
Tiers []DraftKitTier
Empty bool // true if the fetch failed/returned nothing, for an explanatory empty state
}
type SettingsPage struct {
Username string
Leagues []settingsLeagueSummary
Settings UserSettings
CategoryEnabled map[string]bool // action category -> currently enabled, for checkbox state
Saved bool // true right after a successful save, for a confirmation banner
}
type IndexPage struct {
SavedUsername string
SavedUsernames []string
}
// Dashboard types for cross-league overview
type LeagueSummary struct {
LeagueID string
LeagueName string
Season string // "2024", "2025" - year of the league
Scoring string
IsDynasty bool
IsSuperFlex bool
LeagueSize int
// Dynasty metrics
TotalRosterValue int
ValueRank int // 1-12
ValueTrend string // "↗ +5%", "↘ -3%", "→ stable"
AvgAge float64
AgeRank int
DraftPicksSummary string // "2026 1st, 2027 1st, 2nd"
// Season metrics
Record string // "8-5" or empty if offseason
PlayoffStatus string // "Clinched", "In Hunt", "Eliminated", ""
// Action items (for Feature #2)
ActionCount int
LastUpdated time.Time
}
type DashboardPage struct {
Username string
LeagueSummaries []LeagueSummary
TotalLeagues int
DynastyCount int
RedraftCount int
IsOffseason bool // more than a week out from the regular season start
// Cross-league action feed: start/sit swaps, waiver targets, and trade
// opportunities from every league, sorted by priority. Each Action
// carries LeagueName/ID.
ActionFeed []Action
}
// Cache for roster value trends (24h comparison)
type CachedRosterValue struct {
RosterValue int
Timestamp time.Time
}
type valueTrendCache struct {
sync.RWMutex
data map[string]CachedRosterValue // key: "username:leagueID"
ttl time.Duration
}