mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
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:
parent
93d878952c
commit
4bd86d3eb1
2 changed files with 14 additions and 2 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue