Move source mapping to scrape database

This commit is contained in:
2026-08-05 21:40:58 +02:00
parent 17082f6d9e
commit a72bdab9ab
6 changed files with 221 additions and 14 deletions
+10 -3
View File
@@ -129,16 +129,23 @@ export async function listSuggestedProducts(
export async function listMappingSources(config, { manufacturerId, checkUrls = false }) {
try {
const result = await queryEndpoint(config, mappingSourcesSql({ manufacturerId }));
const result = await queryEndpoint(
config,
mappingSourcesSql({
manufacturerId,
scrapeDatabase: config.database?.scrapeName || "catalog_scrape",
}),
);
const mappingTableName = `${config.database?.scrapeName || "catalog_scrape"}.scrape_manufacturer_sources`;
const items = result.items.map((row) =>
normalizeMappingSource(row, "ps_product_catalog_manufacturer_source"),
normalizeMappingSource(row, mappingTableName),
);
const checkedItems = checkUrls ? await checkMappingSourceUrls(items) : items;
return {
configured: result.configured,
mapped: checkedItems.some((item) => item.enabled),
tableName: "ps_product_catalog_manufacturer_source",
tableName: mappingTableName,
items: checkedItems,
sourceCount: checkedItems.filter((item) => item.enabled).length,
testedCount: checkedItems.filter((item) => item.enabled && item.health === "ok").length,