ffl-bigquery 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/CHANGELOG.md +33 -0
  2. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/PKG-INFO +1 -1
  3. ffl_bigquery-0.3.2/ffl_bigquery/_version.py +1 -0
  4. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/driver.py +24 -1
  5. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/rankings.py +6 -4
  6. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/pyproject.toml +1 -1
  7. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_nflverse_driver.py +64 -1
  8. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_nflverse_tables_simple.py +18 -1
  9. ffl_bigquery-0.3.0/ffl_bigquery/_version.py +0 -1
  10. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/.github/workflows/ci.yml +0 -0
  11. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/.github/workflows/release.yml +0 -0
  12. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/.gitignore +0 -0
  13. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/LICENSE +0 -0
  14. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/README.md +0 -0
  15. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/bash.exe.stackdump +0 -0
  16. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/__init__.py +0 -0
  17. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/__init__.py +0 -0
  18. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/ff_opportunity.parquet +0 -0
  19. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/ff_rankings.parquet +0 -0
  20. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/ftn_charting.parquet +0 -0
  21. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/injuries.parquet +0 -0
  22. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/participation.parquet +0 -0
  23. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_schema_samples/snap_counts.parquet +0 -0
  24. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/_transform_util.py +0 -0
  25. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/__init__.py +0 -0
  26. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/ffc.py +0 -0
  27. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/mfl.py +0 -0
  28. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/resolve.py +0 -0
  29. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/schema.py +0 -0
  30. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/sync.py +0 -0
  31. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/adp/transform.py +0 -0
  32. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/cli.py +0 -0
  33. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coaches/__init__.py +0 -0
  34. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coaches/schema.py +0 -0
  35. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coaches/sync.py +0 -0
  36. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coaches/transform.py +0 -0
  37. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coordinators/__init__.py +0 -0
  38. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coordinators/schema.py +0 -0
  39. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coordinators/sync.py +0 -0
  40. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/coordinators/wikipedia.py +0 -0
  41. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/__init__.py +0 -0
  42. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/dst_scoring.py +0 -0
  43. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/dst_weekly.py +0 -0
  44. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/kicker_scoring.py +0 -0
  45. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/kicker_weekly.py +0 -0
  46. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/personnel.py +0 -0
  47. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/points_weekly.py +0 -0
  48. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/derive/scheme_week.py +0 -0
  49. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/http.py +0 -0
  50. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/__init__.py +0 -0
  51. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/runs.py +0 -0
  52. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/spec.py +0 -0
  53. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/__init__.py +0 -0
  54. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/depth_charts.py +0 -0
  55. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/ftn_charting.py +0 -0
  56. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/injuries.py +0 -0
  57. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/opportunity.py +0 -0
  58. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/participation.py +0 -0
  59. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/nflverse/tables/snap_counts.py +0 -0
  60. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/partition.py +0 -0
  61. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/runs.py +0 -0
  62. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/schema.py +0 -0
  63. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/schema_gen.py +0 -0
  64. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/verify/__init__.py +0 -0
  65. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/verify/adp.py +0 -0
  66. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/verify/tables.py +0 -0
  67. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/writer.py +0 -0
  68. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/xref/__init__.py +0 -0
  69. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/xref/schema.py +0 -0
  70. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/xref/sync.py +0 -0
  71. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/ffl_bigquery/xref/transform.py +0 -0
  72. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/conftest.py +0 -0
  73. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/ff_playerids_sample.csv +0 -0
  74. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/ffc_empty_error.json +0 -0
  75. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/ffc_empty_success.json +0 -0
  76. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/ffc_ppr_2015.json +0 -0
  77. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/mfl_adp_2015.json +0 -0
  78. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/mfl_adp_empty_2005.json +0 -0
  79. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/mfl_adp_single_player.json +0 -0
  80. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/nflverse/depth_charts_legacy.parquet +0 -0
  81. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/nflverse/depth_charts_modern.parquet +0 -0
  82. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/fixtures/wikipedia_seasons.json +0 -0
  83. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_ffc.py +0 -0
  84. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_mfl.py +0 -0
  85. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_resolve.py +0 -0
  86. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_schema.py +0 -0
  87. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_sync.py +0 -0
  88. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_adp_transform.py +0 -0
  89. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_cli.py +0 -0
  90. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_clustering_types_are_valid.py +0 -0
  91. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_coaches.py +0 -0
  92. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_coordinators.py +0 -0
  93. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_depth_charts.py +0 -0
  94. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_dst_scoring.py +0 -0
  95. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_dst_weekly.py +0 -0
  96. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_http.py +0 -0
  97. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_kicker_scoring.py +0 -0
  98. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_kicker_weekly.py +0 -0
  99. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_nflverse_runs.py +0 -0
  100. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_nflverse_tables_registry.py +0 -0
  101. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_partition.py +0 -0
  102. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_personnel.py +0 -0
  103. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_play_level_tables.py +0 -0
  104. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_points_weekly.py +0 -0
  105. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_runs.py +0 -0
  106. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_schema.py +0 -0
  107. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_schema_gen.py +0 -0
  108. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_scheme_week.py +0 -0
  109. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_verify_adp.py +0 -0
  110. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_verify_dst.py +0 -0
  111. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_verify_kicker.py +0 -0
  112. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_verify_tables.py +0 -0
  113. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_writer.py +0 -0
  114. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_writer_write_season.py +0 -0
  115. {ffl_bigquery-0.3.0 → ffl_bigquery-0.3.2}/tests/test_xref.py +0 -0
@@ -2,6 +2,39 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.3.2 — 2026-09-29
6
+
7
+ `ff_rankings` MERGE key now includes `page_type`: `(scrape_date, ecr_type, page_type, id)`.
8
+ FantasyPros ranks some players on two position pages (edge rushers appear on both
9
+ dynasty-DL and dynasty-LB) with the same `ecr_type` and `id` but a different rank, so the
10
+ old key was not unique — every snapshot on record has 146–179 such pairs. A first capture
11
+ of a snapshot inserted fine, but any re-run of the same snapshot failed with "UPDATE/MERGE
12
+ must match at most one source row for each target row". `page_type` is never NULL
13
+ upstream and is now REQUIRED in the schema spec.
14
+
15
+ ## 0.3.1 — 2026-09-15
16
+
17
+ Season rollover fix for `sync-nflverse --seasons latest`. `run_sync_nflverse_cli` was
18
+ resolving "latest" as `datetime.now(UTC).year` — the calendar year. NFL seasons are
19
+ labeled by the year they START, and the postseason runs into the following January/
20
+ February, so a run on 2027-01-01 asked for season 2027 when the actual in-flight season
21
+ was still 2026's playoffs. Left alone, the eleven season-chunked nflverse tables would
22
+ have stopped refreshing 2026 mid-postseason and silently never picked up the 2026
23
+ playoffs at all.
24
+
25
+ ### Fixed
26
+
27
+ - `nflverse_season_for_latest(now)` in `ffl_bigquery/nflverse/driver.py` rolls the season
28
+ over in September (matching `nfl_bigquery.sync.current_season()` in the sibling
29
+ library), not on the calendar new year. `run_sync_nflverse_cli` now calls it instead of
30
+ reading `datetime.now(UTC).year` directly whenever the caller doesn't inject an explicit
31
+ `current_season`.
32
+ - **Deliberately not applied to the ADP path.** `ffl_bigquery/adp/sync.py` still resolves
33
+ its season from `snapshot_date.year` (plain calendar year) — that's correct there,
34
+ because in January the ADP board anyone cares about is the *upcoming* draft season, not
35
+ the one that just ended. This asymmetry between the two sync paths is intentional; don't
36
+ "fix" it into consistency.
37
+
5
38
  ## 0.3.0 — 2026-08-07
6
39
 
7
40
  Kicker fantasy scoring. Unlike the DST gap 0.2.0 closed, this one was invisible rather
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ffl-bigquery
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Historical fantasy football ADP, usage, and coaching/scheme data → BigQuery: the fantasy layer on top of nfl-bigquery
5
5
  Project-URL: Homepage, https://github.com/blahovec-labs/ffl-bigquery
6
6
  Project-URL: Issues, https://github.com/blahovec-labs/ffl-bigquery/issues
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -20,6 +20,26 @@ from ffl_bigquery.writer import BigQueryWriter, TableRef
20
20
  log = logging.getLogger(__name__)
21
21
 
22
22
 
23
+ def nflverse_season_for_latest(now: datetime) -> int:
24
+ """Resolve the NFL season a `--seasons latest` nflverse sync should target.
25
+
26
+ NFL seasons are labeled by the year they START, not the calendar year, and
27
+ the season runs into the following January/February for the postseason. A
28
+ run in early January is still fetching the PRIOR season's postseason (e.g.
29
+ a 2027-01-15 run wants season 2026, whose Super Bowl hasn't been played
30
+ yet) -- so the rollover to the new season happens in September, when the
31
+ new season's Week 1 actually starts, not on the calendar new year.
32
+
33
+ This mirrors `nfl_bigquery.sync.current_season()` in the sibling library.
34
+ It is deliberately scoped to the nflverse driver only: `ffl_bigquery.adp.
35
+ sync` resolves its own season from `snapshot_date.year` (calendar year),
36
+ which is correct there because in January the interesting ADP board is
37
+ the *upcoming* draft season, not the one just finished. Don't "fix" that
38
+ asymmetry -- it's intentional.
39
+ """
40
+ return now.year if now.month >= 9 else now.year - 1
41
+
42
+
23
43
  def run_sync_nflverse(
24
44
  specs: list[NflverseTableSpec],
25
45
  *,
@@ -149,7 +169,10 @@ def run_sync_nflverse_cli(
149
169
  runs_table = ns.runs_table or f"{project}.{dataset}._ffl_nflverse_runs"
150
170
  runs_ref = TableRef.parse(runs_table)
151
171
 
152
- season_for_latest = current_season or datetime.now(UTC).year
172
+ season_for_latest = (
173
+ current_season if current_season is not None
174
+ else nflverse_season_for_latest(datetime.now(UTC))
175
+ )
153
176
  seasons = parse_seasons(ns.seasons, season_for_latest)
154
177
 
155
178
  writer = writer or BigQueryWriter(client=bq_client)
@@ -2,8 +2,10 @@
2
2
 
3
3
  Unlike every other table here this is NOT season-chunked -- the loader returns
4
4
  "as of now" with a scrape_date and no season column, so it is snapshot-grain
5
- like ff_adp: MERGE on (scrape_date, ecr_type, id) so re-running the same day is
6
- a no-op, and it becomes a time series only if captured repeatedly.
5
+ like ff_adp: MERGE on (scrape_date, ecr_type, page_type, id) so re-running the same
6
+ day is a no-op, and it becomes a time series only if captured repeatedly. page_type
7
+ is in the key because FantasyPros ranks some players (edge rushers) on two position
8
+ pages -- dynasty-DL and dynasty-LB -- with the same ecr_type and id.
7
9
  """
8
10
  from __future__ import annotations
9
11
 
@@ -16,14 +18,14 @@ from ffl_bigquery.schema import to_bq_schema
16
18
  from ffl_bigquery.schema_gen import specs_from_frame
17
19
  from ffl_bigquery.writer import BigQueryWriter, TableRef
18
20
 
19
- FF_RANKINGS_KEYS = ["scrape_date", "ecr_type", "id"]
21
+ FF_RANKINGS_KEYS = ["scrape_date", "ecr_type", "page_type", "id"]
20
22
  FF_RANKINGS_PARTITION = TimePartition(
21
23
  field="scrape_date", clustering=["ecr_type", "pos"]
22
24
  )
23
25
  FF_RANKINGS_SCHEMA = specs_from_frame(
24
26
  read_sample("ff_rankings"), table="ff_rankings",
25
27
  type_overrides={"scrape_date": "DATE"},
26
- required=("scrape_date", "ecr_type", "id"),
28
+ required=("scrape_date", "ecr_type", "page_type", "id"),
27
29
  enrichment={
28
30
  "ecr": {"semantic_tags": ["metric"],
29
31
  "business_definition": "Expert consensus rank."},
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ffl-bigquery"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Historical fantasy football ADP, usage, and coaching/scheme data → BigQuery: the fantasy layer on top of nfl-bigquery"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -1,10 +1,15 @@
1
1
  import argparse
2
+ from datetime import UTC, datetime
2
3
  from unittest.mock import MagicMock
3
4
 
4
5
  import pandas as pd
5
6
  import pytest
6
7
 
7
- from ffl_bigquery.nflverse.driver import run_sync_nflverse, run_sync_nflverse_cli
8
+ from ffl_bigquery.nflverse.driver import (
9
+ nflverse_season_for_latest,
10
+ run_sync_nflverse,
11
+ run_sync_nflverse_cli,
12
+ )
8
13
  from ffl_bigquery.nflverse.spec import NflverseTableSpec
9
14
  from ffl_bigquery.schema import INGESTED_AT_SPEC, ColumnSpec
10
15
  from ffl_bigquery.writer import TableRef, WriteSeasonResult
@@ -388,3 +393,61 @@ def test_cli_dry_run_still_validates_tables_before_short_circuiting():
388
393
  runs_table=None, resume=False, dry_run=True)
389
394
  with _pytest.raises(ValueError, match="unknown --tables"):
390
395
  run_sync_nflverse_cli(ns, bq_client=None)
396
+
397
+
398
+ def test_nflverse_season_for_latest_january_is_prior_season():
399
+ """A January run is still the previous NFL season's postseason -- the label
400
+ doesn't roll over just because the calendar year did."""
401
+ now = datetime(2027, 1, 15, tzinfo=UTC)
402
+ assert nflverse_season_for_latest(now) == 2026
403
+
404
+
405
+ def test_nflverse_season_for_latest_august_is_prior_season():
406
+ """One month before rollover: still the season that started last September."""
407
+ now = datetime(2026, 8, 31, tzinfo=UTC)
408
+ assert nflverse_season_for_latest(now) == 2025
409
+
410
+
411
+ def test_nflverse_season_for_latest_september_is_current_season():
412
+ """September is when the new NFL season starts -- rollover happens here."""
413
+ now = datetime(2026, 9, 1, tzinfo=UTC)
414
+ assert nflverse_season_for_latest(now) == 2026
415
+
416
+
417
+ def test_nflverse_season_for_latest_december_is_current_season():
418
+ now = datetime(2026, 12, 25, tzinfo=UTC)
419
+ assert nflverse_season_for_latest(now) == 2026
420
+
421
+
422
+ def test_cli_seasons_latest_rolls_over_in_january_without_explicit_current_season():
423
+ """Regression for the rollover bug: without an injected current_season, the
424
+ CLI must still resolve 'latest' via nflverse_season_for_latest (September
425
+ rollover), not datetime.now(UTC).year (calendar-year rollover)."""
426
+ import ffl_bigquery.nflverse.driver as driver_mod
427
+
428
+ calls = []
429
+
430
+ def loader(season: int) -> pd.DataFrame:
431
+ calls.append(season)
432
+ return pd.DataFrame({"season": [season]})
433
+
434
+ class _FrozenDatetime(datetime):
435
+ @classmethod
436
+ def now(cls, tz=None):
437
+ return datetime(2027, 1, 15, tzinfo=tz)
438
+
439
+ original_datetime = driver_mod.datetime
440
+ driver_mod.datetime = _FrozenDatetime
441
+ try:
442
+ w, r = MagicMock(), MagicMock()
443
+ w.write_season.return_value = 1
444
+ r.completed_chunks.return_value = set()
445
+ r.record_success.return_value = True
446
+ run_sync_nflverse_cli(
447
+ _cli_ns(seasons="latest", tables="snap_counts"), bq_client=MagicMock(),
448
+ writer=w, runs=r,
449
+ load_specs=lambda: [_table(name="snap_counts", loader=loader)],
450
+ )
451
+ finally:
452
+ driver_mod.datetime = original_datetime
453
+ assert calls == [2026]
@@ -62,8 +62,25 @@ def test_rankings_is_snapshot_grain_not_season_chunked():
62
62
  FF_RANKINGS_SCHEMA,
63
63
  )
64
64
 
65
- assert FF_RANKINGS_KEYS == ["scrape_date", "ecr_type", "id"]
65
+ assert FF_RANKINGS_KEYS == ["scrape_date", "ecr_type", "page_type", "id"]
66
66
  assert FF_RANKINGS_PARTITION.field == "scrape_date"
67
67
  assert "season" not in spec_names(FF_RANKINGS_SCHEMA)
68
68
  for k in FF_RANKINGS_KEYS:
69
69
  assert next(s for s in FF_RANKINGS_SCHEMA if s.name == k).mode == "REQUIRED"
70
+
71
+
72
+ def test_rankings_keys_keep_a_player_ranked_on_two_position_pages():
73
+ # FantasyPros ranks edge rushers on both the DL and LB pages: same
74
+ # (scrape_date, ecr_type, id), different page_type/ecr. Without page_type in
75
+ # the key the MERGE fails ("must match at most one source row"), which
76
+ # broke ffl-ingest's nflverse run 2026-09-26..29.
77
+ import pandas as pd
78
+
79
+ from ffl_bigquery.nflverse.tables.rankings import FF_RANKINGS_KEYS
80
+
81
+ df = pd.DataFrame({
82
+ "scrape_date": ["2026-09-25", "2026-09-25"], "ecr_type": ["dp", "dp"],
83
+ "id": [16469, 16469], "player": ["T.J. Watt", "T.J. Watt"],
84
+ "page_type": ["dynasty-dl", "dynasty-lb"], "ecr": [15.0, 6.0],
85
+ })
86
+ assert not df.duplicated(FF_RANKINGS_KEYS).any()
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes
File without changes
File without changes