Skip to content

Commit

Permalink
Fix spellbook client
Browse files Browse the repository at this point in the history
  • Loading branch information
ldeluigi committed Nov 13, 2024
1 parent bdc8fbb commit 2e3e3eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bot/discord/spellbook_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
administration_users = [int(user) for user in (os.getenv(f'KUBE_ADMIN_USER__{i}', os.getenv(f'ADMIN_USER__{i}')) for i in range(10)) if user is not None]

MAX_SEARCH_RESULTS = 7
ORDERING = '-popularity,identity_count,card_count,-created'


@bot.command(hidden=True)
Expand Down Expand Up @@ -111,7 +112,7 @@ def add_kwargs(i: int, c: str):
result = await api.variants_list(
q=query_info.patched_query,
limit=MAX_SEARCH_RESULTS,
ordering='-popularity',
ordering=ORDERING,
)
result_count: int = result.count
results: list[Variant] = result.results
Expand Down Expand Up @@ -235,9 +236,9 @@ async def handle_find_my_combos(interaction: discord.Interaction, deck: DeckRequ
async with API() as api_client:
api = FindMyCombosApi(api_client)
if isinstance(deck, str):
result = await find_my_combos_create_plain(api, deck)
result = await find_my_combos_create_plain(api, deck, ordering=ORDERING)
else:
result = await api.find_my_combos_create(deck_request=deck)
result = await api.find_my_combos_create(deck_request=deck, ordering=ORDERING)
results_identity: str = result.results.identity # type: ignore
reply = f'## Find My Combos results for your deck\n### Deck identity: {convert_mana_identity_to_emoji(results_identity)}\n'
results_included: list[Variant] = result.results.included
Expand Down
6 changes: 6 additions & 0 deletions client/python/spellbook_client/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ async def find_my_combos_create_plain(
decklist: str,
limit: Optional[StrictInt] = None,
offset: Optional[StrictInt] = None,
group_by_combo: Optional[bool] = None,
q: Optional[StrictStr] = None,
ordering: Optional[StrictStr] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -27,6 +30,9 @@ async def find_my_combos_create_plain(
deck_request=decklist,
limit=limit,
offset=offset,
group_by_combo=group_by_combo,
q=q,
ordering=ordering,
_request_auth=_request_auth,
_content_type=_content_type or 'text/plain',
_headers=_headers,
Expand Down

0 comments on commit 2e3e3eb

Please sign in to comment.