.PHONY: help deploy_qa_streamlit drop_qa_stremlit 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_qa_streamlit: ## Deploy Streamlit app to QA
	cd streamlit_app && poetry run snow streamlit deploy --replace --connection=fileupload --schema=QA

drop_qa_stremlit: ## Drop Streamlit app and related stage in QA
	poetry run snow streamlit drop fileupload --connection=fileupload --schema=QA && \
	poetry run snow stage drop fileupload_stage --connection=fileupload --schema=QA

push_qa_pycountry_package: ## Load Zip file into FILEUPLOAD_CUSTOM_CODE_STAGE stage in QA
	poetry run snow stage copy pycountry.zip @QA_CRM_FANS.FILEUPLOAD_CUSTOM_CODE_STAGE/ --connection=fileupload

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

drop_prod_stremlit: ## Drop Streamlit app and related stage in PROD
	poetry run snow streamlit drop fileupload --connection=fileupload --schema=PROD && \
	poetry run snow stage drop fileupload_stage --connection=fileupload --schema=PROD

push_prod_pycountry_package: ## Load Zip file into FILEUPLOAD_CUSTOM_CODE_STAGE stage in QA
	poetry run snow stage copy pycountry.zip @PROD_CRM_FANS.FILEUPLOAD_CUSTOM_CODE_STAGE/ --connection=fileupload

run_streamlit_locally: ## Run Streamlit app locally using QA connection
	export target=qa && 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
