.PHONY: help deploy_streamlit_app drop_streamlit_app run_streamlit_locally fmt lint
.DEFAULT_GOAL := help

help:
	@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

deploy_streamlit_app: ## Deploy Streamlit app to PROD
	cd streamlit_app && poetry run snow streamlit deploy --replace --connection=fan_data_export --schema=PROD_STREAMLIT_FAN_EXPORT

drop_streamlit_app: ## Drop Streamlit app and related stage in PROD
	poetry run snow streamlit drop fan_data_export --connection=sme_merch --schema=PROD_STREAMLIT_FAN_EXPORT && \
	poetry run snow stage drop fan_export_stage --connection=sme_merch --schema=PROD_STREAMLIT_FAN_EXPORT

run_streamlit_locally: ## Run Streamlit app locally
	poetry run streamlit run streamlit_app/main.py

fmt: ## Run code formatters
	poetry run ruff check --fix .
	poetry run ruff format .

lint: ## Run code linters
	poetry run mypy .
	poetry run ruff check .
	poetry run ruff format --check .

test: ## Run Snowflake testing using local mocked Sessions
	poetry run pytest streamlit_app --snowflake-session local
