refactor(selection): drop residual concept-sector surface from sub-industry path

- remove the sector_type parameter from the selection port, adapter, and
  use case; the adapter now passes SectorType.INDUSTRY directly, deleting
  the dead concept vocabulary mapping
- stop parsing concepts/concept_total/concept_limit from the sector-radar
  membership response in the web API layer and narrow the response type to
  industries only
- update tests and the task PRD accordingly; backend pyright errors drop
  from the 16 baseline to 14
This commit is contained in:
yuxuanhui
2026-09-06 16:15:08 +08:00
parent 7f93d6b0f5
commit 07c5b25043
10 changed files with 18 additions and 83 deletions
@@ -41,17 +41,15 @@ class FakeSectorReader:
) -> None:
self.counts = counts
self.member_codes = member_codes
self.count_calls: list[tuple[tuple[str, ...], date, str]] = []
self.member_calls: list[tuple[date, str, str]] = []
self.count_calls: list[tuple[tuple[str, ...], date]] = []
self.member_calls: list[tuple[date, str]] = []
def sector_counts(
self,
stock_codes: Sequence[str],
target_trade_date: date,
*,
sector_type: str = "industry",
) -> SelectionSectorMembership:
self.count_calls.append((tuple(stock_codes), target_trade_date, sector_type))
self.count_calls.append((tuple(stock_codes), target_trade_date))
return SelectionSectorMembership(
snapshot_trade_date=target_trade_date,
sector_counts=self.counts,
@@ -61,10 +59,8 @@ class FakeSectorReader:
self,
target_trade_date: date,
sector_code: str,
*,
sector_type: str = "industry",
) -> tuple[str, ...]:
self.member_calls.append((target_trade_date, sector_code, sector_type))
self.member_calls.append((target_trade_date, sector_code))
return self.member_codes
@@ -161,7 +157,7 @@ def test_list_sector_counts_aggregates_only_selected_stocks() -> None:
aggregates = service.list_sector_counts("zhixing_b1")
assert isinstance(aggregates, SelectionSectorAggregates)
assert sector_reader.count_calls == [(("000001.SZ", "000002.SZ"), TARGET, "industry")]
assert sector_reader.count_calls == [(("000001.SZ", "000002.SZ"), TARGET)]
assert aggregates.snapshot_trade_date == TARGET
assert aggregates.sector_type == "industry"
assert aggregates.sectors == sector_reader.counts
@@ -198,7 +194,7 @@ def test_get_latest_resolves_sector_filter_against_run_snapshot() -> None:
)
assert run is store.run
assert sector_reader.member_calls == [(TARGET, "BK0001.DC", "industry")]
assert sector_reader.member_calls == [(TARGET, "BK0001.DC")]
assert store.sector_codes_seen == ("000001.SZ", "000002.SZ")
assert store.queries[-1].sector is None
assert store.queries[-1].page == 2
@@ -239,7 +235,7 @@ def test_get_run_resolves_sector_filter_against_run_snapshot() -> None:
run = service.get_run("run-1", query=SelectionResultQuery(sector="BK0001.DC"))
assert run is store.run
assert sector_reader.member_calls == [(TARGET, "BK0001.DC", "industry")]
assert sector_reader.member_calls == [(TARGET, "BK0001.DC")]
assert store.sector_codes_seen == ("000001.SZ",)