mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-30 16:08:14 +00:00
Now only updates API keys not updated in the last day
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
from eve_api.models.api_player import EVEAccount, EVEPlayerCorporation
|
from eve_api.models.api_player import EVEAccount, EVEPlayerCorporation
|
||||||
import eve_api.api_puller.accounts
|
import eve_api.api_puller.accounts
|
||||||
@@ -11,6 +12,8 @@ class UpdateAPIs():
|
|||||||
|
|
||||||
settings = { 'update_corp': False }
|
settings = { 'update_corp': False }
|
||||||
|
|
||||||
|
last_update_delay = 86400
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _logger(self):
|
def _logger(self):
|
||||||
if not hasattr(self, '__logger'):
|
if not hasattr(self, '__logger'):
|
||||||
@@ -19,7 +22,13 @@ class UpdateAPIs():
|
|||||||
|
|
||||||
def job(self):
|
def job(self):
|
||||||
# Update all the eve accounts and related corps
|
# Update all the eve accounts and related corps
|
||||||
for acc in EVEAccount.objects.all():
|
|
||||||
|
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))
|
||||||
|
self._logger.debug("%s account(s) to update" % len(accounts))
|
||||||
|
for acc in accounts:
|
||||||
self._logger.info("Updating UserID %s" % acc.api_user_id)
|
self._logger.info("Updating UserID %s" % acc.api_user_id)
|
||||||
if not acc.user:
|
if not acc.user:
|
||||||
acc.delete()
|
acc.delete()
|
||||||
|
|||||||
Reference in New Issue
Block a user