Move source mapping to scrape database
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user