view report-templates/data-quality-report.yaml @ 5390:90fc90148ef8 extented-report

Added materialized views based data quality report
author Sascha Wilde <wilde@intevation.de>
date Fri, 02 Jul 2021 18:56:59 +0200
parents
children 014dc3219bdb
line wrap: on
line source

actions:
# One sheet per CC
- type: select
  statement: >
    SELECT cc FROM
      (VALUES ('AT'), ('SK'), ('HU'), ('HR'), ('RS'), ('BG'), ('RO') )
      AS t (cc);
  actions:
  - type: sheet
    source: CCTmpl
    destination: "{{ cc }}"
    vars: [last_row, column_number, offset]
    actions:
    # Header:
    - type: copy
      location: [A1,A5]
    # BN names
    - type: select
      statement: >
        SELECT DISTINCT objnam AS bnnam
          FROM waterway.dqr_bottleneck_stats
          WHERE cc = {{ cc }} ORDER BY objnam;
      actions:
      - type: assign
        name: last_row
        expr: (row_number ?? 0) + 6
      - type: copy
        location: [A6]
        destination: A{{ last_row }}
    - type: copy
      location: [A7]
      destination: A{{ last_row + 1 }}
    # Gen Months
    - type: select
      statement: >
        SELECT to_char(d, 'Month YYYY') AS month, d::date
          FROM generate_series( '2019-10-01'::date,
                                now() - interval '1 day',
                                '1 month'::interval ) d;
      actions:
      - type: assign
        name: column_number
        expr: column2num("B") + (row_number ?? 0) * 2
      - type: copy
        location: [B4,C5]
        destination: '{{ coord2cell(column_number, 4) }}'
      # BN SR-Count
      - type: select
        statement: >
          SELECT objnam, srcnt, fwacnt
            FROM waterway.dqr_bottleneck_stats
            WHERE cc = {{ cc }} AND month = {{ d }}
            ORDER BY objnam;
        actions:
        - type: assign
          name: last_row 
          expr: (row_number ?? 0) + 6
        - type: copy
          location: [B6,C6]
          destination: '{{ coord2cell(column_number, last_row) }}'
      - type: copy
        location: [B7,C7]
        destination: '{{ coord2cell(column_number, last_row + 1) }}'
    - type: assign
      name: offset
      expr: last_row + 3
    #--------------------------------------------------------------------------
    # GAUGES
    # Header:
    - type: copy
      location: [A9]
      destination: A{{ offset }}
    # Gauges names
    - type: select
      statement: >
        SELECT DISTINCT objname AS gnam FROM waterway.dqr_gauge_stats
          WHERE cc = {{ cc }} ORDER BY objname;
      actions:
      - type: assign
        name: last_row
        expr: (row_number ?? 0) + offset + 1
      - type: copy
        location: [A10]
        destination: A{{ last_row }}
    - type: copy
      location: [A11]
      destination: A{{ last_row + 1 }}
    # Gen Months
    - type: select
      statement: >
        SELECT to_char(d, 'Month YYYY') AS month, d::date
          FROM generate_series( '2019-10-01'::date,
                                now() - interval '1 day',
                                '1 month'::interval ) d;
      actions:
      - type: assign
        name: column_number
        expr: column2num("B") + (row_number ?? 0)
      - type: copy
        location: [B9]
        destination: '{{ coord2cell(column_number, offset) }}'
      # BN SR-Count
      - type: select
        statement: >
          SELECT objname, daynodata
            FROM waterway.dqr_gauge_stats
            WHERE cc = {{ cc }} AND month = {{ d }}
            ORDER BY objname;
        actions:
        - type: assign
          name: last_row 
          expr: (row_number ?? 0) + offset + 1
        - type: copy
          location: [B10]
          destination: '{{ coord2cell(column_number, last_row) }}'
      - type: copy
        location: [B11]
        destination: '{{ coord2cell(column_number, last_row + 1) }}'