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

Don't uppercase product name or category when printing info or in visualize title #261

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions scraper/print_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def print_latest_datapoints_for_products(products: list[db.Product]):

for products in grouped_products:
product_infos = db.get_product_infos_from_products(products)
print(product_infos[0].product_name.upper())
print(product_infos[0].product_name)

for product_info in product_infos:
print_latest_datapoint(product_info)
Expand Down Expand Up @@ -56,7 +56,7 @@ def print_all_products() -> None:
return

for category in categories:
print(category.upper())
print(category)

products = db.get_products_by_categories([category])

Expand Down Expand Up @@ -89,7 +89,7 @@ def list_products_with_filters(names: list[str] | None, product_codes: list[str]
sorted_categories = sorted(categories)

for category in sorted_categories:
print(category.upper())
print(category)

products_with_category = [product for product in products_by_filters if product.category == category]

Expand All @@ -100,7 +100,7 @@ def list_products_with_filters(names: list[str] | None, product_codes: list[str]

def list_grouped_products(grouped_products: list[list[Product]]) -> None:
for products in grouped_products:
print(f" > {products[0].name.upper()}")
print(f" > {products[0].name}")
for product in products:
is_active_marker = f"{CHECK_MARK} " if product.is_active else ""
print(f" - {is_active_marker}{product.domain.upper()} - {product.product_code}")
Expand Down
12 changes: 5 additions & 7 deletions scraper/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def visualize_data(

if categories:
for master_product in get_master_products_with_categories(master_products, categories, only_up_to_date):
product_name = master_product.product_name.upper()
category = master_product.category.upper()
product_name = master_product.product_name
category = master_product.category
status_of_master_product = get_status_of_master_product(master_product)
title = f"Price(s) of {product_name} - {category} - {status_of_master_product}"
show_products(master_product.products, title)
Expand All @@ -43,15 +43,15 @@ def visualize_data(
if ids:
for product in get_products_with_ids(master_products, ids, only_up_to_date):
status_of_product = get_status_of_product(product)
product_name = product.product_name.upper()
product_name = product.product_name
title = f"Price(s) of {product_name} - {status_of_product}"
show_product(product, title)
else:
print("No products found with id(s)")

if names:
for master_product in get_master_products_with_names(master_products, names, only_up_to_date):
product_name = master_product.product_name.upper()
product_name = master_product.product_name
status_of_master_product = get_status_of_master_product(master_product)
title = f"Price(s) of {product_name} - {status_of_master_product}"
show_products(master_product.products, title)
Expand Down Expand Up @@ -100,9 +100,7 @@ def show_master_products(master_products: tuple[MasterProduct], only_up_to_date:
continue

status_of_master_product = get_status_of_master_product(master_product)
show_products(
master_product.products, f"Price(s) of {master_product.product_name.upper()} - {status_of_master_product}"
)
show_products(master_product.products, f"Price(s) of {master_product.product_name} - {status_of_master_product}")


def show_product(product: ProductInfo, title: str) -> None:
Expand Down
Loading