mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Role the corp management and corp information update into the API update job
This commit is contained in:
@@ -4,7 +4,5 @@ ROOT=/home/matalok/auth/auth
|
||||
*/10 * * * * $ROOT/run-cron.py reddit.cron ProcessValidations > $ROOT/logs/reddit-validations.log 2>&1
|
||||
*/5 * * * * $ROOT/run-cron.py eve_api.cron UpdateAPIs > $ROOT/logs/eveapi-update.log 2>&1
|
||||
@hourly $ROOT/run-cron.py sso.cron RemoveInvalidUsers > $ROOT/logs/auth-update.log 2>&1
|
||||
@daily $ROOT/run-cron.py eve_api.cron CorpManagementUpdate > $ROOT/logs/corpman-update.log 2>&1
|
||||
0 */6 * * * $ROOT/run-cron.py eve_api.cron AllianceUpdate > $ROOT/logs/alliance-update.log 2>&1
|
||||
@daily $ROOT/run-cron.py eve_proxy.cron ClearStaleCache > $ROOT/logs/cache-clear.log 2>&1
|
||||
0 1 * * 5 $ROOT/run-cron.py eve_api.cron CorporationUpdate > $ROOT/logs/corporation-update.log 2>&1
|
||||
|
||||
@@ -13,7 +13,7 @@ class UpdateAPIs():
|
||||
Updates all Eve API elements in the database
|
||||
"""
|
||||
|
||||
settings = { 'update_corp': False }
|
||||
settings = { 'update_corp': True }
|
||||
|
||||
last_update_delay = 86400
|
||||
batches = 50
|
||||
@@ -38,42 +38,20 @@ class UpdateAPIs():
|
||||
acc.delete()
|
||||
continue
|
||||
eve_api.api_puller.accounts.import_eve_account(acc.api_key, acc.api_user_id)
|
||||
if acc.api_status == API_STATUS_OK:
|
||||
if acc.api_keytype == API_KEYTYPE_FULL and acc.eveplayercharacter_set.filter(director=1).count():
|
||||
for char in acc.eveplayercharacter_set.filter(director=1):
|
||||
pull_corp_members(acc.api_key, acc.api_user_id, char.id)
|
||||
director.corporation.query_and_update_corp()
|
||||
|
||||
if self.settings['update_corp']:
|
||||
for corp in EVEPlayerCorporation.objects.all():
|
||||
for char in acc.eveplayercharacter_set.all():
|
||||
try:
|
||||
corp.query_and_update_corp()
|
||||
char.corporation.query_and_update_corp()
|
||||
except:
|
||||
self._logger.error('Error updating %s' % corp)
|
||||
continue
|
||||
|
||||
class CorpManagementUpdate():
|
||||
"""
|
||||
Pulls character information from corp directors marked in the DB
|
||||
"""
|
||||
|
||||
settings = { 'update_corp': False }
|
||||
|
||||
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):
|
||||
directors = EVEPlayerCharacter.objects.filter(director=True)
|
||||
|
||||
for director in directors:
|
||||
if len(director.eveaccount_set.all()):
|
||||
api = director.eveaccount_set.all()[0]
|
||||
if api.api_keytype == API_KEYTYPE_FULL:
|
||||
self._logger.info("Updating: %s / %s" % (director, director.corporation))
|
||||
pull_corp_members(api.api_key, api.api_user_id, director.id)
|
||||
director.corporation.query_and_update_corp()
|
||||
|
||||
class AllianceUpdate():
|
||||
"""
|
||||
Pulls the AllianceList.xml.aspx and updates the alliance objects
|
||||
@@ -87,20 +65,3 @@ class AllianceUpdate():
|
||||
|
||||
def job(self, args):
|
||||
alliance_import()
|
||||
|
||||
|
||||
class CorporationUpdate():
|
||||
"""
|
||||
Updates all corporate objects in Auth
|
||||
"""
|
||||
|
||||
@property
|
||||
def _logger(self):
|
||||
if not hasattr(self, '__logger'):
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
return self.__logger
|
||||
|
||||
def job(self, args):
|
||||
for corp in set(EVEPlayerCorporation.objects.filter(eveplayercharacter__in=EVEPlayerCharacter.objects.all())):
|
||||
self._logger.debug('Updating %s' % corp)
|
||||
corp.query_and_update_corp()
|
||||
|
||||
Reference in New Issue
Block a user