Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pseudo category 'All' and default to it.
Browse files Browse the repository at this point in the history
DanielO committed Jan 16, 2024
1 parent b764df8 commit 97d698a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library.py
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ def search(self, parameters):
if "package" in parameters and parameters["package"] != "":
p = parameters["package"]
query_chunks.append(f'"Package" LIKE "{p}"')
if "category" in parameters and parameters["category"] != "":
if "category" in parameters and parameters["category"] != "" and parameters["category"] != "All":
p = parameters["category"]
query_chunks.append(f'"First Category" LIKE "{p}"')
if "subcategory" in parameters and parameters["subcategory"] != "":
@@ -529,7 +529,9 @@ def categories(self):
'SELECT DISTINCT "First Category", "Second Category" FROM parts ORDER BY UPPER("First Category"), UPPER("Second Category")'
):
self.category_map.setdefault(row[0], []).append(row[1])
return list(self.category_map.keys())
tmp = list(self.category_map.keys())
tmp.insert(0, 'All')
return tmp

def get_subcategories(self, category):
"""Get the subcategories associated with the given category."""

0 comments on commit 97d698a

Please sign in to comment.