Switch EVE API update job to a recurring task

This commit is contained in:
2010-11-08 17:20:58 +00:00
parent 758db5c535
commit 9b13094fba
2 changed files with 22 additions and 32 deletions

View File

@@ -10,37 +10,6 @@ from eve_api.app_defines import *
from eve_api.tasks import *
class UpdateAPIs():
"""
Updates all Eve API elements in the database
"""
settings = { 'update_corp': True }
last_update_delay = 86400
batches = 50
@property
def _logger(self):
if not hasattr(self, '__logger'):
self.__logger = logging.getLogger(__name__)
return self.__logger
def job(self, args):
# Update all the eve accounts and related corps
delta = datetime.timedelta(seconds=self.last_update_delay)
self._logger.debug("Updating APIs older than %s" % (datetime.datetime.now() - delta))
accounts = EVEAccount.objects.filter(api_last_updated__lt=(datetime.datetime.now() - delta)).exclude(api_status=API_STATUS_ACC_EXPIRED).exclude(api_status=API_STATUS_AUTH_ERROR).order_by('api_last_updated')[:self.batches]
self._logger.debug("%s account(s) to update" % len(accounts))
for acc in accounts:
self._logger.info("Queueing UserID %s for update" % acc.api_user_id)
if not acc.user:
acc.delete()
continue
import_apikey.delay(api_key=acc.api_key, api_userid=acc.api_user_id)
class AllianceUpdate():
"""
Pulls the AllianceList.xml.aspx and updates the alliance objects