From 2bbc060e5cb3d98fc96fc248ee9bdc4e00938261 Mon Sep 17 00:00:00 2001
From: Shaddi Hasan
Date: Thu, 23 Jul 2026 12:41:48 -0400
Subject: [PATCH] Collapse fixed-wireless claims to the fastest per location in
exports
The BDC accepts claims under multiple technologies at one location but
rejects filings claiming more than one fixed-wireless technology
(70/71/72) there. Exports now always keep only the fastest fixed-wireless
claim per location, ranked the same way as the optional
export_max_service_only setting (which is unchanged and still off by
default); claims under other technologies still file alongside.
---
.../database_controller/kml_ops.py | 42 +++++++++++++----
back-end/templates/admin/settings.html | 7 ++-
back-end/tests/test_csv_export.py | 46 +++++++++++++++++--
back-end/tests/test_prod_golden_csv.py | 15 +++---
4 files changed, 89 insertions(+), 21 deletions(-)
diff --git a/back-end/controllers/database_controller/kml_ops.py b/back-end/controllers/database_controller/kml_ops.py
index f998aa6..13b0e9a 100755
--- a/back-end/controllers/database_controller/kml_ops.py
+++ b/back-end/controllers/database_controller/kml_ops.py
@@ -259,14 +259,17 @@ def add_to_db(pandaDF, kmlid, download, upload, tech, wireless, latency, categor
return True
-def filter_max_service(availability_csv):
- """One BDC row per location: the fastest claim wins (download desc, then
- upload desc, then low-latency first, then lowest technology code as a
- deterministic tiebreak). The surviving row keeps its own values. The BDC
- accepts multiple technology claims per location, so this is OPTIONAL
- behavior behind the export_max_service_only site setting — default is to
- report every claim."""
- ordered = availability_csv.sort_values(
+# BDC fixed-wireless technology codes: 70 unlicensed, 71 licensed, 72
+# licensed-by-rule. The BDC rejects a filing claiming more than one of these
+# at a single location, while claims across other technologies may coexist.
+FIXED_WIRELESS_TECH_CODES = (70, 71, 72)
+
+
+def _fastest_first(availability_csv):
+ """Rank claims fastest-first: download desc, then upload desc, then
+ low-latency first, then lowest technology code as a deterministic
+ tiebreak."""
+ return availability_csv.sort_values(
by=[
"max_advertised_download_speed",
"max_advertised_upload_speed",
@@ -276,9 +279,31 @@ def filter_max_service(availability_csv):
ascending=[False, False, False, True],
kind="mergesort",
)
+
+
+def filter_max_service(availability_csv):
+ """One BDC row per location: the fastest claim wins and keeps its own
+ values. The BDC accepts claims under multiple technologies per location,
+ so this is OPTIONAL behavior behind the export_max_service_only site
+ setting — default is to report every claim the BDC will take (see
+ filter_max_fixed_wireless)."""
+ ordered = _fastest_first(availability_csv)
return ordered.drop_duplicates(subset=["location_id"], keep="first")
+def filter_max_fixed_wireless(availability_csv):
+ """At most one fixed-wireless BDC row per location: among claims with a
+ technology in FIXED_WIRELESS_TECH_CODES, only the fastest survives (same
+ ranking as filter_max_service) since the BDC rejects filings claiming two
+ fixed-wireless technologies at one location. Claims under other
+ technologies are untouched. Always applied — this is the shipped default,
+ not a setting."""
+ ordered = _fastest_first(availability_csv)
+ fixed_wireless = ordered[ordered["technology"].isin(FIXED_WIRELESS_TECH_CODES)]
+ losers = fixed_wireless.duplicated(subset=["location_id"], keep="first")
+ return availability_csv.drop(fixed_wireless.index[losers])
+
+
def generate_csv_data(results, provider_id, brand_name, max_service_only=False):
availability_csv = pandas.DataFrame()
@@ -294,6 +319,7 @@ def generate_csv_data(results, provider_id, brand_name, max_service_only=False):
availability_csv.drop_duplicates(
subset=["location_id", "technology"], keep="first", inplace=True
)
+ availability_csv = filter_max_fixed_wireless(availability_csv)
if max_service_only:
availability_csv = filter_max_service(availability_csv)
availability_csv = availability_csv[
diff --git a/back-end/templates/admin/settings.html b/back-end/templates/admin/settings.html
index 79fa635..b6d6baa 100644
--- a/back-end/templates/admin/settings.html
+++ b/back-end/templates/admin/settings.html
@@ -19,8 +19,11 @@
Site settings
Only report maximum service at a location
When on, generated BDC reports include just the fastest claim per location
- (by download, then upload) instead of every technology claim. The BDC accepts multiple
- claims per location, so this is off by default.
+ (by download, then upload) instead of a claim per technology. The BDC accepts claims under
+ multiple technologies per location, so this is off by default. Regardless of this setting,
+ fixed-wireless claims (technology codes 70/71/72) always collapse to the single fastest at
+ each location — the BDC rejects reports claiming more than one fixed-wireless technology
+ there.
{% endblock %}
diff --git a/back-end/tests/test_csv_export.py b/back-end/tests/test_csv_export.py
index 54010b4..784f6d5 100644
--- a/back-end/tests/test_csv_export.py
+++ b/back-end/tests/test_csv_export.py
@@ -49,12 +49,48 @@ def test_provider_and_brand_are_filled():
assert (df.brand_name == "Acme").all()
-def test_default_reports_every_technology_claim():
- """The BDC accepts multiple technology claims per location; by default a
- location under several coverages files a row per technology."""
- rows = [_row(1, tech=50), _row(1, tech=70), _row(1, tech=71)]
+def test_default_reports_every_technology_claim_outside_fixed_wireless():
+ """The BDC accepts multiple technology claims per location as long as at
+ most one is fixed wireless; by default a location under several coverages
+ files a row per (non-conflicting) technology."""
+ rows = [_row(1, tech=50), _row(1, tech=10), _row(1, tech=71)]
df = generate_csv_data(rows, provider_id=330054, brand_name="Acme")
- assert set(zip(df.location_id, df.technology)) == {(1, 50), (1, 70), (1, 71)}
+ assert set(zip(df.location_id, df.technology)) == {(1, 10), (1, 50), (1, 71)}
+
+
+def test_default_collapses_fixed_wireless_to_the_fastest_claim():
+ """The BDC rejects a filing that claims more than one fixed-wireless
+ technology (70/71/72) at a location, so by default only the fastest
+ fixed-wireless claim survives; claims under other technologies still file
+ alongside it."""
+ rows = [
+ _row(1, tech=70, dl=25, ul=3),
+ _row(1, tech=71, dl=100, ul=20), # fastest fixed wireless -> survives
+ _row(1, tech=72, dl=50, ul=10),
+ _row(1, tech=50, dl=1000, ul=1000), # not fixed wireless -> kept too
+ _row(2, tech=70, dl=25, ul=3), # sole fixed-wireless claim -> untouched
+ ]
+ df = generate_csv_data(rows, provider_id=330054, brand_name="Acme")
+ assert set(zip(df.location_id, df.technology)) == {(1, 50), (1, 71), (2, 70)}
+ kept = df[(df.location_id == 1) & (df.technology == 71)].iloc[0]
+ assert kept.max_advertised_download_speed == 100 # the winner's own values
+ assert kept.max_advertised_upload_speed == 20
+
+
+def test_fixed_wireless_collapse_uses_the_max_service_tiebreaks():
+ """The fixed-wireless collapse ranks claims exactly like max_service_only:
+ download desc, then upload desc, then low-latency first, then the lowest
+ technology code."""
+ rows = [
+ _row(2, tech=70, dl=100, ul=50),
+ _row(2, tech=71, dl=100, ul=75), # same download, faster upload -> wins
+ _row(3, tech=72, dl=100, ul=20, latency=1), # low latency wins the tie
+ _row(3, tech=71, dl=100, ul=20, latency=0),
+ _row(4, tech=71, dl=100, ul=20),
+ _row(4, tech=70, dl=100, ul=20), # full tie -> lowest tech code
+ ]
+ df = generate_csv_data(rows, provider_id=330054, brand_name="Acme")
+ assert set(zip(df.location_id, df.technology)) == {(2, 71), (3, 72), (4, 70)}
def test_max_service_only_picks_the_fastest_claim_per_location():
diff --git a/back-end/tests/test_prod_golden_csv.py b/back-end/tests/test_prod_golden_csv.py
index a80da32..27f7e5c 100644
--- a/back-end/tests/test_prod_golden_csv.py
+++ b/back-end/tests/test_prod_golden_csv.py
@@ -3,12 +3,15 @@
prod actually stored (the BDC report the provider filed).
This pins the export-layer behavior that kml_data equality cannot see. The
-shipped default reports every (location, technology) claim — the BDC accepts
-multiple claims per location — which matches the reference era pinned here.
-(Some historical snapshots were generated with a since-retired per-location
-wireless dedup; they stay in the fixture set as reference only — see
-csv-golden.json. The optional export_max_service_only setting, pinned by
-unit tests in test_csv_export.py, is the supported variant of that idea.)
+shipped default reports every (location, technology) claim the BDC will
+accept: claims under multiple technologies may coexist at a location, but at
+most one fixed-wireless claim (tech 70/71/72) survives — the fastest — since
+the BDC rejects filings claiming two fixed-wireless technologies at one
+location. The pinned reference exports were filed under that one-fixed-
+wireless-row shape. (Earlier report-every-claim-era snapshots stay in the
+fixture set as reference only — see csv-golden.json. The optional
+export_max_service_only setting, pinned by unit tests in test_csv_export.py,
+further collapses to a single row per location.)
References: prod-extract//output/prod-stored-export.csv and
prod-extract/csv-golden.json, which maps each upload folder to the stored