Skip to content

Instantly share code, notes, and snippets.

@nicklewis
Created April 25, 2017 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicklewis/d46a22b22f6272a89322f3ebe917eee3 to your computer and use it in GitHub Desktop.
Save nicklewis/d46a22b22f6272a89322f3ebe917eee3 to your computer and use it in GitHub Desktop.
WITH inactive_nodes
AS (SELECT certname
FROM certnames
WHERE ( deactivated IS NOT NULL
OR expired IS NOT NULL ))
SELECT reports.certname AS certname,
Encode(reports.hash :: bytea, 'hex') AS hash,
reports.end_time AS end_time,
reports.noop AS noop,
report_statuses.status AS status,
reports.noop_pending AS noop_pending,
reports.corrective_change AS corrective_change
FROM reports
left join environments
ON environments.id = reports.environment_id
left join producers
ON producers.id = reports.producer_id
left join report_statuses
ON reports.status_id = report_statuses.id
WHERE ( ( Encode(reports.hash :: bytea, 'hex') ) IN (SELECT
Encode(reports.hash :: bytea, 'hex') AS latest_report_hash
FROM certnames
left join catalogs
ON catalogs.certname
=
certnames.certname
left join factsets fs
ON certnames.certname
= fs.certname
left join reports
ON
certnames.latest_report_id = reports.id
left join environments
catalog_environment
ON
catalog_environment.id = catalogs.environment_id
left join report_statuses
ON reports.status_id
=
report_statuses.id
left join environments
facts_environment
ON
facts_environment.id = fs.environment_id
left join environments
reports_environment
ON
reports_environment.id = reports.environment_id
WHERE
certnames.certname = ANY ( $1 )) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment