Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update function 'compare_products' to compare all products when parameter 'show_all' is true #252

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading