Skip to content

Commit

Permalink
fix: handle empty filter values and simplify get_all_filters
Browse files Browse the repository at this point in the history
(cherry picked from commit 7fd8a16)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Dec 12, 2023
1 parent 4da0954 commit 4d0eb7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Empty file added hrms/www/jobs/__init__.py
Empty file.
20 changes: 7 additions & 13 deletions hrms/www/jobs/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,15 @@ def get_all_filters(filters=None):
fields=["company", "department", "location", "employment_type"],
)

companies = filters["company"] if "company" in filters else None
companies = filters.get("company", [])

all_filters = {}
for d in job_openings:
for key, value in d.items():
if key == "company" or not companies or (companies and d["company"] in companies):
if key not in all_filters:
all_filters[key] = [value]
elif value and value not in all_filters[key]:
all_filters[key].append(value)

for d in all_filters:
all_filters[d].sort()

return all_filters
for opening in job_openings:
for key, value in opening.items():
if value and (key == "company" or not companies or opening.company in companies):
all_filters.setdefault(key, set()).add(value)

return {key: sorted(value) for key, value in all_filters.items()}


def get_filters_txt_and_order_by(orders):
Expand Down

0 comments on commit 4d0eb7e

Please sign in to comment.