From ae4c73b081508e96764f6fec6a393b2403a60b80 Mon Sep 17 00:00:00 2001 From: paco Date: Wed, 27 Sep 2023 19:29:17 +0000 Subject: [PATCH] add env variable example --- model/cubes/defaults.py | 10 ++++++++++ model/cubes/{line_items.yml => line_items.yml.jinja} | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 model/cubes/defaults.py rename model/cubes/{line_items.yml => line_items.yml.jinja} (88%) diff --git a/model/cubes/defaults.py b/model/cubes/defaults.py new file mode 100644 index 0000000..e411c18 --- /dev/null +++ b/model/cubes/defaults.py @@ -0,0 +1,10 @@ +import os +from cube import context_func + +@context_func +def get_scheduled_refresh(): + name = 'CUSTOM_ENV_PREAGGS_ENABLE' + if name in os.environ: + return str(str(os.environ[name]).lower() == 'true').lower() + return 'false' + diff --git a/model/cubes/line_items.yml b/model/cubes/line_items.yml.jinja similarity index 88% rename from model/cubes/line_items.yml rename to model/cubes/line_items.yml.jinja index 8f66548..ab4eb2d 100644 --- a/model/cubes/line_items.yml +++ b/model/cubes/line_items.yml.jinja @@ -1,3 +1,5 @@ +{% set scheduled_refresh = get_scheduled_refresh() %} + cubes: - name: line_items sql_table: ECOM.LINE_ITEMS @@ -32,7 +34,7 @@ cubes: pre_aggregations: - name: line_items_summary - scheduled_refresh: false + scheduled_refresh: {{ scheduled_refresh }} measures: - count - total_amount