Skip to content

Conversation

@sreyassabbani
Copy link
Contributor

@sreyassabbani sreyassabbani commented Jan 17, 2025

See #8

This should work now, for both tossups & bonuses on both Sync and Async clients.

Example:

c = Sync()

print(c.random_tossup(alternate_subcategories=["Poetry"])[0])

This will send a GET request to the QB Reader API endpoint, automatically adding subcategories=Other%20Literature on to the querystring.

And for the async example:

a = Async()

async def t():
    a = await Async.create()

    print(
        (await a.random_tossup(alternate_subcategories=["Math"]))[0]
    )

    print(
        (await a.random_bonus(alternate_subcategories=["Computer Science"]))[0]
    )
    
    await a.close()

print(asyncio.run(t()))

- modified `_api_utils.py`
- breaking change to `normalize_subcats()` function
@sreyassabbani sreyassabbani changed the title Feature: alternate subcat support (#8) Feature: alternate subcat support Jan 17, 2025
@sreyassabbani
Copy link
Contributor Author

I did see some oopsies after PR-ing. I believe we're going to have to squash those commits before merging.

@geoffrey-wu
Copy link
Member

I added some commits, the gist is that:

  • You were correct initially that you should use .get for alternate_subcategory since not all questions have it
  • For literature, the alternate subcategory corresponds to the Literature category, not the Other Literature subcategory. This is confusing because in this context, alternate_subcategory is a true alternate subcategory, but in all other contexts, it should be called "subsubcategory". This is a low priority issue but will likely be fixed in the future.

@geoffrey-wu geoffrey-wu merged commit 291ff56 into qbreader:main Jan 17, 2025
5 of 8 checks passed
@skysomorphic skysomorphic removed their request for review January 17, 2025 21:17
sreyassabbani added a commit to sreyassabbani/qbreader-python-module that referenced this pull request Jan 17, 2025
sreyassabbani added a commit to sreyassabbani/qbreader-python-module that referenced this pull request Jan 17, 2025
geoffrey-wu added a commit that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

max_year and min_year parameters incorrectly passed to api Support alternate_subcategory

2 participants