Count Channels with any of the Tags in the Other search estimate

The Other tab lists Channels with any of the selected Tags, but its estimate
only counted Channels with the first Tag, so the two disagreed when several
Tags were selected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-10-07 15:23:48 -06:00
parent 93d878952c
commit 4bd86d3eb1
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 14 additions and 2 deletions

View file

@ -2885,11 +2885,11 @@ async def search_other_estimates(session: Session, tag_names: List[str], search_
repo_count=repo_count,
)
# TODO handle multiple tags
# Matches `search_channels`: Channels with any of the Tags.
channel_count = session.query(func.count(Channel.id)) \
.join(Collection, Collection.id == Channel.collection_id) \
.join(Tag, Tag.id == Collection.tag_id) \
.filter(Tag.name == tag_names[0]) \
.filter(Tag.name.in_(tag_names)) \
.scalar()
others = dict(

View file

@ -1016,6 +1016,18 @@ async def test_search_other_estimates(async_client, test_session, channel_factor
assert response.status_code == HTTPStatus.OK
assert response.json['others']['channel_count'] == 1, 'Only one Channel is tagged.'
# The estimate counts the Channels the search lists: those with any of the Tags.
tag2 = await tag_factory()
channel_factory(tag_name=tag2.name)
test_session.commit()
body = dict(tag_names=[tag.name, tag2.name])
request, response = await async_client.post('/api/search_other_estimates', json=body)
assert response.status_code == HTTPStatus.OK
estimate = response.json['others']['channel_count']
request, response = await async_client.post('/api/videos/channels/search', json=body)
assert response.status_code == HTTPStatus.OK
assert estimate == len(response.json['channels']) == 2
@pytest.mark.asyncio
async def test_mutating_request_survives_concurrent_writer(async_client, test_session, test_downloader,