Skip to content

Commit

Permalink
HOTFIX: Fix groupby method
Browse files Browse the repository at this point in the history
  • Loading branch information
tarto-dev committed Feb 15, 2024
1 parent 8b884fc commit e56401f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def get_product_details_from_api(product: str, majors_only: bool):
"""
details = API.get_product_details(product=product)
if majors_only:
# Sort the details by major version number
details.sort(key=lambda x: int(x["cycle"].split(".")[0]))

# Group the details by major version number
groups = groupby(details, key=lambda x: x["cycle"].split(".")[0])

# Take the first entry from each group
details = [next(group) for _, group in groups]
excluded_minors_products = []
latest_major = 0
for entry in details:
if entry["cycle"].split(".")[0] != latest_major:
excluded_minors_products.append(entry)
latest_major = entry["cycle"].split(".")[0]

details = excluded_minors_products

return details

Expand Down

0 comments on commit e56401f

Please sign in to comment.