Skip to content

Commit

Permalink
quick change for current date [ci-skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jdemlow committed Aug 22, 2024
1 parent ec5f172 commit 552ea17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion all_in_one_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion storage/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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());
""")

Expand Down
3 changes: 1 addition & 2 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)",
Expand Down

0 comments on commit 552ea17

Please sign in to comment.