Skip to content

Commit

Permalink
chore: Refactor search functions to use type parameter (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
M7mdisk authored Aug 26, 2024
1 parent 885e8dc commit 5ec0d29
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions webapp/search/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,16 @@ def filter_topics(topics):


def search_charms(term: str, limit: int):
packages = app.store_api.find(term, fields=SEARCH_FIELDS)
charms = [
package
for package in packages["results"]
if package["type"] == "charm"
packages = app.store_api.find(term, type="charm", fields=SEARCH_FIELDS)[
"results"
]

return charms[:limit]
return packages[:limit]


def search_bundles(term: str, limit: int):
packages = app.store_api.find(term, fields=SEARCH_FIELDS)
bundles = [
package
for package in packages["results"]
if package["type"] == "bundle"
packages = app.store_api.find(term, type="bundle", fields=SEARCH_FIELDS)[
"results"
]

return bundles[:limit]
return packages[:limit]

0 comments on commit 5ec0d29

Please sign in to comment.