first commit

This commit is contained in:
2026-03-19 22:54:29 +03:30
parent 1a178f39b7
commit 035bc6f74d
91 changed files with 3821 additions and 130 deletions
+34
View File
@@ -0,0 +1,34 @@
"""
تسک‌های Celery برای واکشی داده‌های هواشناسی.
"""
from config.celery import app
from location_data.models import SoilLocation
from .services import update_weather_for_location, update_weather_for_all_locations
@app.task(bind=True)
def fetch_weather_task(self, location_id: int):
"""
واکشی پیش‌بینی هواشناسی ۷ روزه برای یک location مشخص.
"""
try:
location = SoilLocation.objects.get(pk=location_id)
except SoilLocation.DoesNotExist:
return {
"status": "error",
"error": f"SoilLocation with id={location_id} not found.",
}
return update_weather_for_location(location)
@app.task(bind=True)
def fetch_weather_all_locations_task(self):
"""
واکشی پیش‌بینی هواشناسی برای تمام location‌ها.
مناسب برای Celery Beat (مثلاً هر ۶ ساعت).
"""
return update_weather_for_all_locations()