Skip to content

Commit 7965d1b

Browse files
Jonathan FreedCathy Li
authored andcommitted
[Explore Sites] Fixing SQL query to gather icons for category tiles.
Previously, the SQL query included site icons that were NULL or empty, resulting in category tiles often having less than 4 site icons present. This fix skips the empty icons, and grabs the next non-empty ones. Change-Id: I314c78f1797769e598640d06162811e1672c2449 Reviewed-on: https://chromium-review.googlesource.com/c/1279155 Reviewed-by: Peter Williamson <[email protected]> Commit-Queue: Jonathan Freed <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#599347}(cherry picked from commit cdef234) Reviewed-on: https://chromium-review.googlesource.com/c/1285097 Reviewed-by: Cathy Li <[email protected]> Cr-Commit-Position: refs/branch-heads/3578@{#72} Cr-Branched-From: 4226ddf-refs/heads/master@{#599034}
1 parent 3a770c9 commit 7965d1b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

chrome/browser/android/explore_sites/get_images_task.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ namespace {
1616
const char kSelectCategoryImagesSql[] = R"(SELECT favicon
1717
FROM sites
1818
LEFT JOIN site_blacklist ON (sites.url = site_blacklist.url)
19-
WHERE category_id = ? AND NOT removed AND site_blacklist.url IS NULL
19+
WHERE category_id = ? AND LENGTH(favicon) > 0 AND NOT removed
20+
AND site_blacklist.url IS NULL
2021
LIMIT ?;)";
2122

2223
const char kSelectSiteImageSql[] =

chrome/browser/android/explore_sites/get_images_task_unittest.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,25 @@ VALUES
175175
EXPECT_EQ(4U, last_result.size());
176176
}
177177

178+
TEST_F(ExploreSitesGetImagesTaskTest, SkipMissingFavicons) {
179+
PopulateTestingCatalog();
180+
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
181+
sql::Statement insert(db->GetUniqueStatement(R"(
182+
INSERT INTO sites
183+
(site_id, url, category_id, title, favicon)
184+
VALUES
185+
(5, "https://www.example.com/5", 3, "example_5", NULL),
186+
(6, "https://www.example.com/6", 3, "example_6", ""),
187+
(7, "https://www.example.com/7", 3, "example_7", "bytes7");
188+
)"));
189+
return insert.Run();
190+
}));
191+
GetImagesTask task(store(), 3, 3, StoreResult());
192+
RunTask(&task);
193+
194+
EXPECT_EQ(3U, last_result.size());
195+
std::vector<uint8_t>& result3 = *last_result[2];
196+
EXPECT_EQ("bytes7", std::string(result3.begin(), result3.end()));
197+
}
198+
178199
} // namespace explore_sites

0 commit comments

Comments
 (0)