From 7a1d7e5996b0b78fac53e722dc2b865d1819f1fa Mon Sep 17 00:00:00 2001 From: Nan Jiang Date: Mon, 3 Feb 2025 14:49:28 -0500 Subject: [PATCH] fix: Remove hardcoded chrome image URIs from top picks --- dev/top_picks.json | 10 +-- docs/manifest.md | 2 +- .../jobs/navigational_suggestions/__init__.py | 6 +- merino/jobs/navigational_suggestions/utils.py | 22 ------ .../api/v1/manifest/test_manifest.py | 2 +- tests/unit/conftest.py | 2 +- .../test_navigational_suggestions_utils.py | 70 ------------------- 7 files changed, 9 insertions(+), 105 deletions(-) diff --git a/dev/top_picks.json b/dev/top_picks.json index 1f3ed7129..a64a06d84 100644 --- a/dev/top_picks.json +++ b/dev/top_picks.json @@ -8,7 +8,7 @@ ], "url": "https://www.google.com", "title": "Google", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/google-com@2x.png", + "icon": "", "serp_categories": [ 18 ] @@ -62,7 +62,7 @@ ], "url": "https://www.youtube.com", "title": "YouTube", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/youtube-com@2x.png", + "icon": "", "serp_categories": [ 0 ] @@ -75,7 +75,7 @@ ], "url": "https://twitter.com", "title": "Twitter", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/twitter-com@2x.png", + "icon": "", "serp_categories": [ 16 ] @@ -182,7 +182,7 @@ ], "url": "https://www.bing.com", "title": "Bing", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/bing-com@2x.svg", + "icon": "", "serp_categories": [ 18 ] @@ -10089,4 +10089,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/docs/manifest.md b/docs/manifest.md index 9ad948670..0d09de46c 100644 --- a/docs/manifest.md +++ b/docs/manifest.md @@ -24,7 +24,7 @@ The `/manifest` endpoint returns a curated list of websites with associated meta ], "url": "https://www.google.com/", "title": "Google", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/google-com@2x.png" + "icon": "" }, { "rank": 2, diff --git a/merino/jobs/navigational_suggestions/__init__.py b/merino/jobs/navigational_suggestions/__init__.py index 816a747c5..c62722beb 100644 --- a/merino/jobs/navigational_suggestions/__init__.py +++ b/merino/jobs/navigational_suggestions/__init__.py @@ -22,9 +22,6 @@ from merino.jobs.navigational_suggestions.domain_metadata_uploader import ( DomainMetadataUploader, ) -from merino.jobs.navigational_suggestions.utils import ( - update_top_picks_with_firefox_favicons, -) from merino.providers.suggest.base import Category from merino.utils.blocklists import TOP_PICKS_BLOCKLIST @@ -158,9 +155,8 @@ def prepare_domain_metadata( uploaded_favicons = domain_metadata_uploader.upload_favicons(favicons) logger.info("domain favicons uploaded to GCS") - # construct top pick contents, update them with firefox packaged favicons and upload to gcs + # construct top pick contents top_picks = _construct_top_picks(domain_data, uploaded_favicons, domain_metadata) - update_top_picks_with_firefox_favicons(top_picks) # Create diff class for comparison of Top Picks Files old_top_picks: dict[str, list[dict[str, str]]] | None = ( diff --git a/merino/jobs/navigational_suggestions/utils.py b/merino/jobs/navigational_suggestions/utils.py index 8c9e6b712..623ff1cd5 100644 --- a/merino/jobs/navigational_suggestions/utils.py +++ b/merino/jobs/navigational_suggestions/utils.py @@ -23,14 +23,6 @@ TIMEOUT: int = 10 -# Some high resolution domain favicons that are internally packaged in Firefox -FIREFOX_PACKAGED_FAVICONS: dict[str, str] = { - "google": "chrome://activity-stream/content/data/content/tippytop/images/google-com@2x.png", - "bing": "chrome://activity-stream/content/data/content/tippytop/images/bing-com@2x.svg", - "youtube": "chrome://activity-stream/content/data/content/tippytop/images/youtube-com@2x.png", - "twitter": "chrome://activity-stream/content/data/content/tippytop/images/twitter-com@2x.png", -} - logger = logging.getLogger(__name__) @@ -74,17 +66,3 @@ def requests_get(url: str) -> requests.Response | None: timeout=TIMEOUT, ) return response if response.status_code == 200 else None - - -def update_top_picks_with_firefox_favicons( - top_picks: dict[str, list[dict[str, str]]], -) -> None: - """Update top picks with high resolution favicons that are internally packaged in firefox - for some of the selected domains for which favicon scraping didn't return anything - """ - domains_metadata: list[dict[str, str]] = top_picks["domains"] - for domain_metadata in domains_metadata: - domain = domain_metadata["domain"] - firefox_favicon: str | None = FIREFOX_PACKAGED_FAVICONS.get(domain) - if firefox_favicon: - domain_metadata["icon"] = firefox_favicon diff --git a/tests/integration/api/v1/manifest/test_manifest.py b/tests/integration/api/v1/manifest/test_manifest.py index 4eb7e8976..48e376c8c 100644 --- a/tests/integration/api/v1/manifest/test_manifest.py +++ b/tests/integration/api/v1/manifest/test_manifest.py @@ -23,7 +23,7 @@ def mock_manifest_2025() -> dict: "serp_categories": [0], "url": "https://www.spotify.com", "title": "Spotify", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/google-com@2x.png", + "icon": "", } ] } diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 37c1d1cde..7c0956099 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -79,7 +79,7 @@ def fixture_blob_json() -> str: "serp_categories": [0], "url": "https://www.google.com/", "title": "Google", - "icon": "chrome://activity-stream/content/data/content/tippytop/images/google-com@2x.png", + "icon": "", }, { "rank": 2, diff --git a/tests/unit/jobs/navigational_suggestions/test_navigational_suggestions_utils.py b/tests/unit/jobs/navigational_suggestions/test_navigational_suggestions_utils.py index d4ad88e54..6fb254f6c 100644 --- a/tests/unit/jobs/navigational_suggestions/test_navigational_suggestions_utils.py +++ b/tests/unit/jobs/navigational_suggestions/test_navigational_suggestions_utils.py @@ -12,79 +12,9 @@ from merino.jobs.navigational_suggestions.utils import ( REQUEST_HEADERS, FaviconDownloader, - update_top_picks_with_firefox_favicons, ) -def test_update_top_picks_with_firefox_favicons_favicon_added_for_special_domains(): - """Test that top picks is updated with firefox favicon for special domains - when scraped available to top picks - """ - input_top_picks = { - "domains": [ - { - "rank": 1, - "domain": "google", - "categories": ["Search Engines"], - "url": "https://www.google.com", - "title": "Google", - "icon": "", - }, - ] - } - - updated_top_picks = { - "domains": [ - { - "rank": 1, - "domain": "google", - "categories": ["Search Engines"], - "url": "https://www.google.com", - "title": "Google", - "icon": ( - "chrome://activity-stream/content/data/content/tippytop/" - "images/google-com@2x.png" - ), - }, - ] - } - - update_top_picks_with_firefox_favicons(input_top_picks) - assert input_top_picks == updated_top_picks - - -def test_update_top_picks_with_firefox_favicons_favicon_not_added_for_non_special_domains(): - """Test that top picks is not updated with firefox favicon for non special domains""" - input_top_picks = { - "domains": [ - { - "rank": 2, - "domain": "facebook", - "categories": ["Social Networks"], - "url": "https://www.facebook.com", - "title": "Facebook \u2013 log in or sign up", - "icon": "", - }, - ] - } - - updated_top_picks = { - "domains": [ - { - "rank": 2, - "domain": "facebook", - "categories": ["Social Networks"], - "url": "https://www.facebook.com", - "title": "Facebook \u2013 log in or sign up", - "icon": "", - }, - ] - } - - update_top_picks_with_firefox_favicons(input_top_picks) - assert input_top_picks == updated_top_picks - - def test_favicon_downloader(requests_mock): """Test FaviconDownloader using requests_mock""" requests_mock.register_uri(