install:
	pip install -r requirements.txt

clean:
	rm -rf ~/.local/share/controles/database.db*
	rm -f admin_qr.png

init-db: clean
	python init_db.py

seed: init-db
	python seed.py

init:
	python app.py --init

run:
	python app.py

run-with-seed: seed init run

reset-admin: clean
	python create_admin.py

# Docker commands
docker-build:
	docker-compose build

docker-up:
	docker-compose up -d

docker-down:
	docker-compose down

docker-logs:
	docker-compose logs -f

docker-restart:
	docker-compose restart

# Redis cache commands
cache-clear:
	docker-compose exec redis redis-cli FLUSHDB

cache-status:
	docker-compose exec redis redis-cli INFO

cache-keys:
	docker-compose exec redis redis-cli KEYS "*"

# Development with Docker
dev-up: docker-build docker-up
	@echo "Development environment started with Redis cache"
	@echo "Application: http://localhost:5000"
	@echo "Redis: localhost:6379"

dev-down: docker-down
	@echo "Development environment stopped"

# Production commands
prod-build:
	docker-compose -f docker-compose.yml build --no-cache

prod-up:
	docker-compose -f docker-compose.yml up -d

prod-logs:
	docker-compose -f docker-compose.yml logs -f app

# Cache management
cache-warmup:
	@echo "Warming up cache..."
	curl -X GET http://localhost:5000/api/dashboard/stats
	curl -X GET http://localhost:5000/api/dashboard/militante-stats
	curl -X GET http://localhost:5000/api/dashboard/financial-stats
	@echo "Cache warmup completed"

cache-monitor:
	@echo "Monitoring Redis cache..."
	watch -n 5 'docker-compose exec redis redis-cli INFO memory'
