from functools import cached_property

from django.apps import AppConfig


class WeatherConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "weather"
    verbose_name = "Weather Forecast"

    @cached_property
    def farm_weather_service(self):
        from .farm_weather import FarmWeatherService

        return FarmWeatherService()

    def get_farm_weather_service(self):
        return self.farm_weather_service

    @cached_property
    def water_need_service(self):
        from .water_need_prediction import WaterNeedPredictionService

        return WaterNeedPredictionService()

    def get_water_need_service(self):
        return self.water_need_service

    @cached_property
    def weather_data_adapter(self):
        from .adapters import get_weather_adapter

        return get_weather_adapter()

    def get_weather_data_adapter(self):
        return self.weather_data_adapter

    def update_weather_for_location(self, location):
        from .services import update_weather_for_location

        return update_weather_for_location(location)
