28 lines
1.1 KiB
SQL
28 lines
1.1 KiB
SQL
{% macro count_bookings_by_service_status() %}
|
|
{% set service_status_map = {
|
|
"PROTECTED": "number_protected_bookings",
|
|
"REJECTED": "number_rejected_bookings",
|
|
"NOCHECKS": "number_no_checks_bookings",
|
|
"NOFLAGS": "number_no_flags_bookings",
|
|
"PAID": "number_paid_bookings",
|
|
"PENDING": "number_pending_bookings",
|
|
"-": "number_unknown_status_bookings",
|
|
"PARTIALLY PROTECTED": "number_partially_protected_bookings",
|
|
"NOT PROTECTED": "number_not_protected_bookings",
|
|
"NOT PAID": "number_not_paid_bookings",
|
|
"CONFIRMED": "number_confirmed_bookings",
|
|
"FORREVIEW": "number_for_review_bookings",
|
|
"FLAGGED": "number_flagged_bookings",
|
|
} %}
|
|
|
|
{% for status, alias in service_status_map.items() %}
|
|
count(
|
|
distinct case
|
|
when upper(ub.service_status) = '{{ status }}'
|
|
then (ub.id_booking)
|
|
else null
|
|
end
|
|
) as {{ alias }}
|
|
{% if not loop.last %}, {% endif %}
|
|
{% endfor %}
|
|
{% endmacro %}
|