diff --git a/all_in_one_app.py b/all_in_one_app.py index 482a588..4f61633 100644 --- a/all_in_one_app.py +++ b/all_in_one_app.py @@ -133,7 +133,11 @@ def run_command(query): STORAGE_BYTES as total_active_bytes, STAGE_BYTES as total_stage_bytes, FAILSAFE_BYTES as total_failsafe_bytes - FROM snowflake.account_usage.storage_usage + FROM ( + SELECT * + FROM snowflake.account_usage.storage_usage + WHERE usage_date < CURRENT_DATE() + ) WHERE USAGE_DATE = (SELECT MAX(USAGE_DATE) FROM snowflake.account_usage.storage_usage) ) SELECT diff --git a/storage/forecast.py b/storage/forecast.py index d410ebe..ccd6620 100644 --- a/storage/forecast.py +++ b/storage/forecast.py @@ -9,7 +9,12 @@ def generate_storage_forecast(training_days, predicted_days): SELECT TO_TIMESTAMP_NTZ(usage_date) AS usage_date, storage_bytes / POWER(1024, 3) AS storage_gb - FROM snowflake.account_usage.storage_usage + FROM + ( + SELECT * + FROM snowflake.account_usage.storage_usage + WHERE usage_date < CURRENT_DATE() + ) WHERE TO_TIMESTAMP_NTZ(usage_date) < DATEADD(day, -{training_days}, CURRENT_DATE()); """) diff --git a/streamlit_app.py b/streamlit_app.py index 8f31e1c..696c04d 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -10,7 +10,6 @@ from storage.forecast import generate_storage_forecast from storage.recommendations import generate_recommendations, display_recommendations - # Initialize session state if 'storage_data' not in st.session_state: st.session_state.storage_data = None @@ -75,7 +74,7 @@ STAGE_BYTES as total_stage_bytes, FAILSAFE_BYTES as total_failsafe_bytes FROM snowflake.account_usage.storage_usage - WHERE USAGE_DATE = (SELECT MAX(USAGE_DATE) FROM snowflake.account_usage.storage_usage) + WHERE USAGE_DATE = DATEADD(day, -1, (SELECT MAX(USAGE_DATE) FROM snowflake.account_usage.storage_usage)) ) SELECT ROUND(total_active_bytes / POWER(1024, 3), 1) AS "Active Storage (GB)",