fix(community-issues): scrapeTransceiverCompatIssues falls back to ports_config when no compat entries
This commit is contained in:
parent
02c8554f56
commit
b7e146c026
@ -403,14 +403,29 @@ export async function findAndSeedDatasheetLinks(limit = 50): Promise<void> {
|
||||
// Scrape transceiver-specific issues per switch (switch + transceiver combos)
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
export async function scrapeTransceiverCompatIssues(switchLimit = 20): Promise<void> {
|
||||
// Get switches that have compatibility entries — search for their transceiver issues
|
||||
// Prefer switches with known compatibility entries; fall back to switches with port_config
|
||||
const result = await pool.query<{ switch_model: string; form_factors: string[] }>(
|
||||
`SELECT sw.model AS switch_model,
|
||||
ARRAY_AGG(DISTINCT t.form_factor) AS form_factors
|
||||
COALESCE(
|
||||
ARRAY_AGG(DISTINCT t.form_factor) FILTER (WHERE t.form_factor IS NOT NULL),
|
||||
-- Fall back: extract form factors from ports_config keys
|
||||
ARRAY(SELECT DISTINCT
|
||||
CASE
|
||||
WHEN k LIKE '%QSFP-DD%' THEN 'QSFP-DD'
|
||||
WHEN k LIKE '%QSFP28%' THEN 'QSFP28'
|
||||
WHEN k LIKE '%QSFP%' THEN 'QSFP+'
|
||||
WHEN k LIKE '%SFP28%' THEN 'SFP28'
|
||||
WHEN k LIKE '%SFP%' THEN 'SFP+'
|
||||
WHEN k LIKE '%OSFP%' THEN 'OSFP'
|
||||
END
|
||||
FROM jsonb_object_keys(sw.ports_config) AS k
|
||||
WHERE sw.ports_config IS NOT NULL
|
||||
)
|
||||
) AS form_factors
|
||||
FROM switches sw
|
||||
JOIN compatibility c ON c.switch_id = sw.id
|
||||
JOIN transceivers t ON c.transceiver_id = t.id
|
||||
GROUP BY sw.model
|
||||
LEFT JOIN compatibility c ON c.switch_id = sw.id
|
||||
LEFT JOIN transceivers t ON c.transceiver_id = t.id
|
||||
GROUP BY sw.model, sw.ports_config
|
||||
ORDER BY COUNT(c.id) DESC
|
||||
LIMIT $1`,
|
||||
[switchLimit],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user