Skip to content

Commit

Permalink
move to mgmt commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Mar 11, 2024
1 parent 7e01dd3 commit 6819c19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 3 additions & 0 deletions api/tacticalrmm/core/management/commands/post_update_tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64

from django.core.management import call_command
from django.core.management.base import BaseCommand

from accounts.models import User
Expand Down Expand Up @@ -54,4 +55,6 @@ def handle(self, *args, **kwargs) -> None:

agent.save(update_fields=["goarch"])

call_command("remove_orphaned_history_results")
call_command("sync_mesh_with_trmm")
self.stdout.write("Post update tasks finished")
14 changes: 3 additions & 11 deletions api/tacticalrmm/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import nats
from django.conf import settings
from django.db import transaction
from django.core.management import call_command
from django.db.models import Prefetch
from django.db.utils import DatabaseError
from django.utils import timezone as djangotime
Expand All @@ -20,7 +20,7 @@
from alerts.models import Alert
from alerts.tasks import prune_resolved_alerts
from autotasks.models import AutomatedTask, TaskResult
from checks.models import Check, CheckHistory, CheckResult
from checks.models import Check, CheckResult
from checks.tasks import prune_check_history
from clients.models import Client, Site
from core.mesh_utils import (
Expand Down Expand Up @@ -68,15 +68,7 @@ def core_maintenance_tasks() -> None:
remove_if_not_scheduled=True, expire_date__lt=djangotime.now()
).delete()

with transaction.atomic():
check_hist_agentids = CheckHistory.objects.values_list(
"agent_id", flat=True
).distinct()
current_agentids = set(Agent.objects.values_list("agent_id", flat=True))
orphaned_agentids = [
i for i in check_hist_agentids if i not in current_agentids
]
CheckHistory.objects.filter(agent_id__in=orphaned_agentids).delete()
call_command("remove_orphaned_history_results")

core = get_core_settings()

Expand Down
1 change: 0 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ python manage.py create_installer_user
python manage.py create_natsapi_conf
python manage.py create_uwsgi_conf
python manage.py clear_redis_celery_locks
python manage.py sync_mesh_with_trmm
python manage.py post_update_tasks
echo "Running management commands...please wait..."
API=$(python manage.py get_config api)
Expand Down

0 comments on commit 6819c19

Please sign in to comment.