Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Fix feed parameter in /search command (#203)
Browse files Browse the repository at this point in the history
* Fix query parameter to filter by feed

* Make /r/ prefix optional in feed parameter

* Fix lint errors
  • Loading branch information
TimJentzsch authored May 29, 2023
1 parent e6961f8 commit f00a4fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions buttercup/cogs/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from buttercup.cogs.helpers import (
BlossomException,
BlossomUser,
extract_sub_name,
get_discord_time_str,
get_duration_str,
get_initial_username,
Expand Down Expand Up @@ -269,7 +270,8 @@ async def _search_from_cache(

from_str = after_time.isoformat() if after_time else None
until_str = before_time.isoformat() if before_time else None
feed = feed if feed else None
feed = "/r/" + extract_sub_name(feed) if feed else None
feed_str = feed if feed else "all feeds"

request_page = (discord_page * self.discord_page_size) // self.request_page_size

Expand All @@ -280,7 +282,7 @@ async def _search_from_cache(
"author": user_id,
"create_time__gte": from_str,
"create_time__lte": until_str,
"feed": feed,
"submission__feed__iexact": feed,
"url__isnull": False,
"ordering": "-create_time",
"page_size": self.request_page_size,
Expand All @@ -299,7 +301,7 @@ async def _search_from_cache(
query=query,
user=get_username(user),
time_str=time_str,
feed_str=feed if feed else "all feeds",
feed_str=feed_str,
duration_str=get_duration_str(start),
)
)
Expand Down Expand Up @@ -344,6 +346,7 @@ async def _search_from_cache(
query=query,
user=get_username(user),
time_str=time_str,
feed_str=feed_str,
duration_str=get_duration_str(start),
),
embed=Embed(
Expand Down
2 changes: 1 addition & 1 deletion buttercup/strings/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ search:
more_occurrences: |-
... and {count} more occurrence(s).
embed_message: |-
Here are your results for `{query}` in transcriptions by {user} {time_str}! ({duration_str})
Here are your results for `{query}` in transcriptions by {user} {time_str} in {feed_str}! ({duration_str})
embed_title: |-
Results for `{query}` by {user}
embed_footer: |-
Expand Down

0 comments on commit f00a4fe

Please sign in to comment.