Skip to content

Commit

Permalink
Merge pull request #252 from Crinibus/update-argument-compare-to-supp…
Browse files Browse the repository at this point in the history
…ort-argument-all

Update function 'compare_products' to compare all products when parameter 'show_all' is true
  • Loading branch information
Crinibus authored Jul 13, 2024
2 parents 4db2745 + 489e5d8 commit 7f454a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scraper/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def visualize_data(
master_products = get_master_products()

if compare:
compare_products(master_products, ids, names, categories, only_up_to_date)
compare_products(master_products, ids, names, categories, only_up_to_date, show_all)
return

if show_all:
Expand Down Expand Up @@ -50,7 +50,12 @@ def visualize_data(


def compare_products(
master_products: tuple[MasterProduct], ids: list[str], names: list[str], categories: list[str], only_up_to_date: bool
master_products: tuple[MasterProduct],
ids: list[str],
names: list[str],
categories: list[str],
only_up_to_date: bool,
show_all: bool,
) -> None:
master_products_with_names = get_master_products_with_names(master_products, names, only_up_to_date)
products_with_names = get_products_from_master_products(master_products_with_names)
Expand All @@ -62,6 +67,9 @@ def compare_products(

products_to_compare = [*products_with_ids, *products_with_names, *products_with_categories]

if show_all:
products_to_compare = get_products_from_master_products(master_products)

product_ids = [product.id for product in products_to_compare]
product_ids_string = ", ".join(product_ids)
title_ = product_ids_string[:100] + " ..." if len(product_ids_string) > 100 else product_ids_string
Expand Down

0 comments on commit 7f454a3

Please sign in to comment.