feat(appliance): initial release of MERICA standalone appliance v1.0.0
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- dbt Gold Model: fct_spku_daily_mart
|
||||
{{ config(materialized='table', schema='gold') }}
|
||||
|
||||
SELECT
|
||||
stasiun_id,
|
||||
nama_stasiun_clean,
|
||||
AVG(ispu_value) AS avg_daily_ispu,
|
||||
MAX(ispu_value) AS max_daily_ispu,
|
||||
COUNT(*) AS total_readings,
|
||||
CURRENT_DATE AS mart_date
|
||||
FROM {{ ref('stg_spku_realtime') }}
|
||||
GROUP BY stasiun_id, nama_stasiun_clean
|
||||
@@ -0,0 +1,9 @@
|
||||
-- dbt Gold Regulatory Compliance Mart
|
||||
SELECT
|
||||
permit_type,
|
||||
status,
|
||||
COUNT(permit_id) AS total_permits,
|
||||
COUNT(DISTINCT company_name) AS unique_companies,
|
||||
CURRENT_TIMESTAMP AS mart_refreshed_at
|
||||
FROM {{ ref('silver_permits_enriched') }}
|
||||
GROUP BY permit_type, status
|
||||
@@ -0,0 +1,21 @@
|
||||
-- dbt Gold Industrial Emission Compliance & Load Mart
|
||||
SELECT
|
||||
region_zone,
|
||||
industry_sector,
|
||||
COUNT(log_id) AS total_telemetry_events,
|
||||
COUNT(DISTINCT source_id) AS active_chimneys_count,
|
||||
ROUND(AVG(so2_mg_nm3), 2) AS avg_so2_concentration,
|
||||
ROUND(AVG(nox_mg_nm3), 2) AS avg_nox_concentration,
|
||||
ROUND(AVG(pm_dust_mg_nm3), 2) AS avg_pm_concentration,
|
||||
ROUND(SUM(so2_mass_rate_kg_h) / 1000.0, 3) AS total_so2_emission_ton,
|
||||
ROUND(SUM(nox_mass_rate_kg_h) / 1000.0, 3) AS total_nox_emission_ton,
|
||||
ROUND(SUM(pm_mass_rate_kg_h) / 1000.0, 3) AS total_pm_emission_ton,
|
||||
COUNT(CASE WHEN compliance_status = 'EXCEEDING_LIMIT' THEN 1 END) AS total_violations_count,
|
||||
ROUND(
|
||||
(COUNT(CASE WHEN compliance_status = 'COMPLIANT' THEN 1 END)::NUMERIC / NULLIF(COUNT(log_id), 0)) * 100.0,
|
||||
2
|
||||
) AS compliance_rate_percent,
|
||||
CURRENT_TIMESTAMP AS mart_refreshed_at
|
||||
FROM {{ ref('silver_cems_emission_enriched') }}
|
||||
GROUP BY region_zone, industry_sector
|
||||
ORDER BY total_violations_count DESC, total_so2_emission_ton DESC
|
||||
@@ -0,0 +1,16 @@
|
||||
{{ config(
|
||||
materialized='table',
|
||||
schema='gold'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
stasiun_id,
|
||||
nama_stasiun,
|
||||
CAST(recorded_at AS DATE) AS observation_date,
|
||||
AVG(pm25_value) AS avg_pm25,
|
||||
MAX(pm25_value) AS max_pm25,
|
||||
AVG(pm10_value) AS avg_pm10,
|
||||
MAX(pm10_value) AS max_pm10,
|
||||
CURRENT_TIMESTAMP AS refreshed_at_gold
|
||||
FROM {{ ref('silver_spku_sensor_clean') }}
|
||||
GROUP BY 1, 2, 3
|
||||
@@ -0,0 +1,13 @@
|
||||
{{ config(
|
||||
materialized='table',
|
||||
schema='gold'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
CAST(issued_date AS DATE) AS permit_date,
|
||||
permit_type,
|
||||
permit_status,
|
||||
COUNT(permit_id) AS total_permits,
|
||||
CURRENT_TIMESTAMP AS refreshed_at_gold
|
||||
FROM {{ ref('silver_environmental_permits_clean') }}
|
||||
GROUP BY 1, 2, 3
|
||||
@@ -0,0 +1,16 @@
|
||||
-- dbt Gold Regional Waste Revenue & Compliance Mart
|
||||
SELECT
|
||||
region_zone,
|
||||
facility_type,
|
||||
waste_category,
|
||||
COUNT(order_id) AS total_orders,
|
||||
COUNT(DISTINCT facility_id) AS active_facilities_count,
|
||||
COUNT(DISTINCT generator_company) AS active_generators_count,
|
||||
ROUND(SUM(volume_ton), 2) AS total_waste_volume_ton,
|
||||
ROUND(SUM(total_order_amount), 2) AS total_gross_revenue,
|
||||
ROUND(AVG(total_order_amount / NULLIF(volume_ton, 0)), 2) AS avg_revenue_per_ton,
|
||||
COUNT(CASE WHEN environmental_compliance_status = 'COMPLIANT' THEN 1 END) AS compliant_orders_count,
|
||||
CURRENT_TIMESTAMP AS mart_refreshed_at
|
||||
FROM {{ ref('silver_waste_manifest_enriched') }}
|
||||
GROUP BY region_zone, facility_type, waste_category
|
||||
ORDER BY total_waste_volume_ton DESC
|
||||
@@ -0,0 +1,14 @@
|
||||
{{ config(
|
||||
materialized='table',
|
||||
schema='gold'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
kecamatan,
|
||||
tanggal_laporan,
|
||||
COUNT(lokasi_tps) AS total_tps,
|
||||
SUM(volume_sampah_m3) AS total_volume_sampah_m3,
|
||||
AVG(volume_sampah_m3) AS avg_volume_per_tps_m3,
|
||||
CURRENT_TIMESTAMP AS refreshed_at_gold
|
||||
FROM {{ ref('silver_gws_waste_reports_clean') }}
|
||||
GROUP BY 1, 2
|
||||
@@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: gold_compliance_summary_mart
|
||||
description: dbt Model gold_compliance_summary_mart auto-registered with Shift-Left
|
||||
quality assertions
|
||||
columns:
|
||||
- name: permit_type
|
||||
tests:
|
||||
- not_null
|
||||
- name: status
|
||||
tests:
|
||||
- not_null
|
||||
Reference in New Issue
Block a user