mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	use django timezone'd datetime to squash timezone warnings from worker heartbeat
This commit is contained in:
		@@ -6,7 +6,8 @@ import json
 | 
				
			|||||||
import requests
 | 
					import requests
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from datetime import datetime, timedelta
 | 
					from datetime import timedelta
 | 
				
			||||||
 | 
					from django.utils import timezone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.core.exceptions import AppRegistryNotReady
 | 
					from django.core.exceptions import AppRegistryNotReady
 | 
				
			||||||
from django.db.utils import OperationalError, ProgrammingError
 | 
					from django.db.utils import OperationalError, ProgrammingError
 | 
				
			||||||
@@ -125,7 +126,7 @@ def heartbeat():
 | 
				
			|||||||
    except AppRegistryNotReady:
 | 
					    except AppRegistryNotReady:
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    threshold = datetime.now() - timedelta(minutes=30)
 | 
					    threshold = timezone.now() - timedelta(minutes=30)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Delete heartbeat results more than half an hour old,
 | 
					    # Delete heartbeat results more than half an hour old,
 | 
				
			||||||
    # otherwise they just create extra noise
 | 
					    # otherwise they just create extra noise
 | 
				
			||||||
@@ -149,7 +150,7 @@ def delete_successful_tasks():
 | 
				
			|||||||
        logger.info("Could not perform 'delete_successful_tasks' - App registry not ready")
 | 
					        logger.info("Could not perform 'delete_successful_tasks' - App registry not ready")
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    threshold = datetime.now() - timedelta(days=30)
 | 
					    threshold = timezone.now() - timedelta(days=30)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    results = Success.objects.filter(
 | 
					    results = Success.objects.filter(
 | 
				
			||||||
        started__lte=threshold
 | 
					        started__lte=threshold
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user