summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-03-25 14:43:56 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-03-25 14:43:56 +0700
commit3af3dcebb085de4afef6d7381b574149f8e90ccc (patch)
tree38c83eb53ee676fa97650535db26c483dca8464f
parentb355e154c605afea2d14ff7daa81c23af9b0ece5 (diff)
add refresh materialized view
-rw-r--r--import_brand.ktr58
-rw-r--r--refresh_materialized_view.ktr135
2 files changed, 176 insertions, 17 deletions
diff --git a/import_brand.ktr b/import_brand.ktr
index d006f22..b9273c5 100644
--- a/import_brand.ktr
+++ b/import_brand.ktr
@@ -436,14 +436,14 @@
<notepads>
</notepads>
<connection>
- <name>dw bi indoteknik</name>
+ <name>dw bi indoteknik (localhost)</name>
<server>localhost</server>
<type>POSTGRESQL</type>
<access>Native</access>
<database>dw_bi_indoteknik</database>
- <port>5703</port>
- <username>metabase</username>
- <password>Encrypted 2be98dfba28d7bf86853c9f58cfc4f889</password>
+ <port>5432</port>
+ <username>odoo</username>
+ <password>Encrypted 2be98afc82bdfd8dd9a2ca45acc83f6c3</password>
<servername/>
<data_tablespace/>
<index_tablespace/>
@@ -462,7 +462,7 @@
</attribute>
<attribute>
<code>PORT_NUMBER</code>
- <attribute>5703</attribute>
+ <attribute>5432</attribute>
</attribute>
<attribute>
<code>PRESERVE_RESERVED_WORD_CASE</code>
@@ -478,7 +478,7 @@
</attribute>
<attribute>
<code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
- <attribute>Y</attribute>
+ <attribute>N</attribute>
</attribute>
<attribute>
<code>USE_POOLING</code>
@@ -487,12 +487,12 @@
</attributes>
</connection>
<connection>
- <name>erp indoteknik production</name>
- <server>localhost</server>
+ <name>erp indoteknik production (localhost)</name>
+ <server>10.148.0.3</server>
<type>POSTGRESQL</type>
<access>Native</access>
<database>erp_indoteknik</database>
- <port>5901</port>
+ <port>5432</port>
<username>odoo</username>
<password>Encrypted 2be98afc82bdfd8dd9a2ca45acc83f6c3</password>
<servername/>
@@ -513,7 +513,7 @@
</attribute>
<attribute>
<code>PORT_NUMBER</code>
- <attribute>5901</attribute>
+ <attribute>5432</attribute>
</attribute>
<attribute>
<code>PRESERVE_RESERVED_WORD_CASE</code>
@@ -529,7 +529,7 @@
</attribute>
<attribute>
<code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
- <attribute>Y</attribute>
+ <attribute>N</attribute>
</attribute>
<attribute>
<code>USE_POOLING</code>
@@ -555,12 +555,14 @@
<method>none</method>
<schema_name/>
</partitioning>
- <connection>erp indoteknik production</connection>
+ <connection>erp indoteknik production (localhost)</connection>
<sql>select id, x_name, x_manufacture_level,
(select x_name from x_manufactures xm2 where xm2.id = xm.parent_id) as parent, pricing_group,
(select name from product_public_category ppc where ppc.id in(select product_public_category_id
from product_public_category_x_manufactures_rel where x_manufactures_id = xm.id limit 1)) as category,
-override_vendor_id
+override_vendor_id,
+(select product_public_category_id
+ from product_public_category_x_manufactures_rel where x_manufactures_id = xm.id limit 1) as category_id
from x_manufactures xm
where xm.write_date >= (now() - '15 days'::interval)</sql>
<limit>0</limit>
@@ -731,6 +733,29 @@ where xm.write_date >= (now() - '15 days'::interval)</sql>
<date_format_timezone>Asia/Bangkok</date_format_timezone>
<lenient_string_to_number>N</lenient_string_to_number>
</value-meta>
+ <value-meta>
+ <type>Integer</type>
+ <storagetype>normal</storagetype>
+ <name>category_id</name>
+ <length>9</length>
+ <precision>0</precision>
+ <origin>Table input</origin>
+ <comments>category_id</comments>
+ <conversion_Mask>####0;-####0</conversion_Mask>
+ <decimal_symbol>.</decimal_symbol>
+ <grouping_symbol>,</grouping_symbol>
+ <currency_symbol/>
+ <trim_type>none</trim_type>
+ <case_insensitive>N</case_insensitive>
+ <collator_disabled>Y</collator_disabled>
+ <collator_strength>0</collator_strength>
+ <sort_descending>N</sort_descending>
+ <output_padding>N</output_padding>
+ <date_format_lenient>N</date_format_lenient>
+ <date_format_locale>en_ID</date_format_locale>
+ <date_format_timezone>Asia/Bangkok</date_format_timezone>
+ <lenient_string_to_number>N</lenient_string_to_number>
+ </value-meta>
</row-meta>
<attributes/>
<cluster_schema/>
@@ -757,7 +782,7 @@ where xm.write_date >= (now() - '15 days'::interval)</sql>
<method>none</method>
<schema_name/>
</partitioning>
- <connection>dw bi indoteknik</connection>
+ <connection>dw bi indoteknik (localhost)</connection>
<commit>100</commit>
<update_bypassed>N</update_bypassed>
<lookup>
@@ -804,6 +829,11 @@ where xm.write_date >= (now() - '15 days'::interval)</sql>
<rename>override_vendor_id</rename>
<update>Y</update>
</value>
+ <value>
+ <name>category_id</name>
+ <rename>category_id</rename>
+ <update>Y</update>
+ </value>
</lookup>
<attributes/>
<cluster_schema/>
diff --git a/refresh_materialized_view.ktr b/refresh_materialized_view.ktr
index 7e2bb98..5435816 100644
--- a/refresh_materialized_view.ktr
+++ b/refresh_materialized_view.ktr
@@ -522,6 +522,21 @@
<to>growth salesperson</to>
<enabled>Y</enabled>
</hop>
+ <hop>
+ <from>growth salesperson</from>
+ <to>invoice customer group by brand and year</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>invoice customer group by brand and year</from>
+ <to>growth brand per year</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>growth brand per year</from>
+ <to>growth category brand per year</to>
+ <enabled>Y</enabled>
+ </hop>
</order>
<step>
<name>accurate</name>
@@ -714,6 +729,44 @@
</GUI>
</step>
<step>
+ <name>growth salesperson</name>
+ <type>ExecSQL</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>dw bi indoteknik (localhost)</connection>
+ <execute_each_row>N</execute_each_row>
+ <single_statement>N</single_statement>
+ <replace_variables>N</replace_variables>
+ <quoteString>N</quoteString>
+ <sql>refresh materialized view mv_growth_salesperson</sql>
+ <set_params>N</set_params>
+ <insert_field/>
+ <update_field/>
+ <delete_field/>
+ <read_field/>
+ <arguments>
+ </arguments>
+ <attributes/>
+ <cluster_schema/>
+ <remotesteps>
+ <input>
+ </input>
+ <output>
+ </output>
+ </remotesteps>
+ <GUI>
+ <xloc>1200</xloc>
+ <yloc>304</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
+ <step>
<name>salesperson</name>
<type>ExecSQL</type>
<description/>
@@ -790,7 +843,7 @@
</GUI>
</step>
<step>
- <name>growth salesperson</name>
+ <name>invoice customer group by brand and year</name>
<type>ExecSQL</type>
<description/>
<distribute>Y</distribute>
@@ -805,7 +858,7 @@
<single_statement>N</single_statement>
<replace_variables>N</replace_variables>
<quoteString>N</quoteString>
- <sql>refresh materialized view mv_growth_salesperson</sql>
+ <sql>refresh materialized view mv_invoice_customer_group_brand_year</sql>
<set_params>N</set_params>
<insert_field/>
<update_field/>
@@ -822,7 +875,83 @@
</output>
</remotesteps>
<GUI>
- <xloc>1200</xloc>
+ <xloc>944</xloc>
+ <yloc>304</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
+ <step>
+ <name>growth brand per year</name>
+ <type>ExecSQL</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>dw bi indoteknik (localhost)</connection>
+ <execute_each_row>N</execute_each_row>
+ <single_statement>N</single_statement>
+ <replace_variables>N</replace_variables>
+ <quoteString>N</quoteString>
+ <sql>refresh materialized view mv_brand_per_year</sql>
+ <set_params>N</set_params>
+ <insert_field/>
+ <update_field/>
+ <delete_field/>
+ <read_field/>
+ <arguments>
+ </arguments>
+ <attributes/>
+ <cluster_schema/>
+ <remotesteps>
+ <input>
+ </input>
+ <output>
+ </output>
+ </remotesteps>
+ <GUI>
+ <xloc>720</xloc>
+ <yloc>304</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
+ <step>
+ <name>growth category brand per year</name>
+ <type>ExecSQL</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>dw bi indoteknik (localhost)</connection>
+ <execute_each_row>N</execute_each_row>
+ <single_statement>N</single_statement>
+ <replace_variables>N</replace_variables>
+ <quoteString>N</quoteString>
+ <sql>refresh materialized view mv_category_brand_per_year</sql>
+ <set_params>N</set_params>
+ <insert_field/>
+ <update_field/>
+ <delete_field/>
+ <read_field/>
+ <arguments>
+ </arguments>
+ <attributes/>
+ <cluster_schema/>
+ <remotesteps>
+ <input>
+ </input>
+ <output>
+ </output>
+ </remotesteps>
+ <GUI>
+ <xloc>560</xloc>
<yloc>304</yloc>
<draw>Y</draw>
</GUI>