diff --git a/backend/coreAdmin/celery.py b/backend/coreAdmin/celery.py index 9422fb5b..d672ed62 100644 --- a/backend/coreAdmin/celery.py +++ b/backend/coreAdmin/celery.py @@ -36,22 +36,22 @@ "schedule": crontab(minute=0, hour="*/3"), # 'schedule': 30.0 }, - "prediction-map-every-30-minutes": { - "task": "tno.tasks.create_thumbnail_maps", - # a job is scheduled to run for every first minute of every hour - # "schedule": crontab(hour="*", minute=1), - "schedule": crontab(minute="*/30"), - }, + # "prediction-map-every-30-minutes": { + # "task": "tno.tasks.create_thumbnail_maps", + # # a job is scheduled to run for every first minute of every hour + # # "schedule": crontab(hour="*", minute=1), + # "schedule": crontab(minute="*/30"), + # }, # Executes every Monday morning at 2:00 a.m. - "update_asteroid_table-every-monday": { - "task": "tno.tasks.update_asteroid_table", - "schedule": crontab(hour=2, minute=0, day_of_week=1), - }, + # "update_asteroid_table-every-monday": { + # "task": "tno.tasks.update_asteroid_table", + # "schedule": crontab(hour=2, minute=0, day_of_week=1), + # }, # Executes every Day at 5:00 a.m. - "predict_job_for_updated_asteroids": { - "task": "tno.tasks.predict_jobs_by_updated_asteroids", - "schedule": crontab(hour=5, minute=0), - }, + # "predict_job_for_updated_asteroids": { + # "task": "tno.tasks.predict_jobs_by_updated_asteroids", + # "schedule": crontab(hour=5, minute=0), + # }, # # Executes every 10th and 25th day of every month. # "predict_job_for_upper_end_update": { # "task": "tno.tasks.predict_jobs_for_upper_end_update", diff --git a/backend/tno/management/commands/create_thumbnail_maps.py b/backend/tno/management/commands/create_thumbnail_maps.py index b29cf14a..916228de 100644 --- a/backend/tno/management/commands/create_thumbnail_maps.py +++ b/backend/tno/management/commands/create_thumbnail_maps.py @@ -28,8 +28,9 @@ def handle(self, *args, **options): start_date = options.get("start") end_date = options.get("end") + if end_date: + end_date = end_date + " 23:59:59.999" limit = options.get("limit", 1000) - to_run = upcoming_events_to_create_maps(start_date, end_date, limit) self.stdout.write(f"Tasks to be executed in this block: [{len(to_run)}].") diff --git a/backend/tno/prediction_map.py b/backend/tno/prediction_map.py index e5b10ede..c56354a7 100644 --- a/backend/tno/prediction_map.py +++ b/backend/tno/prediction_map.py @@ -1,6 +1,6 @@ import logging import os -from datetime import datetime, time, timezone +from datetime import datetime, timedelta, timezone from itertools import groupby from operator import itemgetter from pathlib import Path @@ -113,7 +113,6 @@ def upcoming_events_to_create_maps( date_start: Optional[str] = None, date_end: Optional[str] = None, limit: Optional[int] = None, - magnitude_limit: Optional[int] = 15, ) -> list: logger = logging.getLogger("predict_maps") logger.info(f"Looking for upcoming events") @@ -140,25 +139,43 @@ def upcoming_events_to_create_maps( if date_start == None: date_start = datetime.now(timezone.utc) # Corrected UTC handling + if date_end == None: + date_end = date_start + timedelta(days=1) if isinstance(date_start, str): date_start = datetime.fromisoformat(date_start).astimezone(tz=timezone.utc) - next_events = Occultation.objects.filter(date_time__gte=date_start) - if isinstance(date_end, str): date_end = datetime.fromisoformat(date_end).astimezone(tz=timezone.utc) - next_events = next_events.filter(date_time__lte=date_end) - next_events = next_events.order_by("g_star") + next_events = ( + Occultation.objects.filter(date_time__range=(date_start, date_end)) + .order_by("g_star") + .only( + "name", + "diameter", + "ra_star_candidate", + "dec_star_candidate", + "date_time", + "closest_approach", + "position_angle", + "velocity", + "delta", + "g_star", + "long", + "closest_approach_uncertainty", + ) + ) - logger.info(f"Next events count: {next_events.count()}") - logger.info(f"Query: {next_events.query}") + number_of_events = next_events.count() + logger.info(f"Next events count: {number_of_events}") + block_size = min(block_size, number_of_events) + # logger.info(f"Query: {next_events.query}") # lets avoid bring all data reached_block_size = False i = 0 - while not reached_block_size: + while not reached_block_size and (i * block_size) < number_of_events: event_data = next_events[i * block_size : (i + 1) * block_size] diff --git a/frontend/src/contexts/PredictionContext.js b/frontend/src/contexts/PredictionContext.js index 0affa29f..25336e06 100644 --- a/frontend/src/contexts/PredictionContext.js +++ b/frontend/src/contexts/PredictionContext.js @@ -28,7 +28,7 @@ export function PredictionEventsProvider({ children }) { maginitudeDropMin: undefined, diameterMin: undefined, diameterMax: undefined, - closestApproachUncertainty: 100, + closestApproachUncertainty: 500, eventDurationMin: undefined, geo: false, latitude: undefined,