mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Change when 'has-jobs-<>' cache key gets set
We should set the cache after the job has been created, in case there was an HTTP error when creating the job.
This commit is contained in:
@@ -97,12 +97,6 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
return bool(self.get_jobs(service_id)['data'])
|
||||
|
||||
def create_job(self, job_id, service_id, scheduled_for=None):
|
||||
redis_client.set(
|
||||
'has_jobs-{}'.format(service_id),
|
||||
b'true',
|
||||
ex=cache.TTL,
|
||||
)
|
||||
|
||||
data = {"id": job_id}
|
||||
|
||||
if scheduled_for:
|
||||
@@ -111,6 +105,12 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
data = _attach_current_user(data)
|
||||
job = self.post(url='/service/{}/job'.format(service_id), data=data)
|
||||
|
||||
redis_client.set(
|
||||
'has_jobs-{}'.format(service_id),
|
||||
b'true',
|
||||
ex=cache.TTL,
|
||||
)
|
||||
|
||||
stats = self.__convert_statistics(job['data'])
|
||||
job['data']['notifications_sent'] = stats['delivered'] + stats['failed']
|
||||
job['data']['notifications_delivered'] = stats['delivered']
|
||||
|
||||
Reference in New Issue
Block a user