Commit 4846edf7 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

refactor

parent 5f540ca6
...@@ -21,8 +21,7 @@ class Service: ...@@ -21,8 +21,7 @@ class Service:
def run_job(self, job): def run_job(self, job):
job = Job.objects.get(pk=job) job = Job.objects.get(pk=job)
uuid = self.api.schedule('exa', job.spider.sp_name, query=job.query) job.job_uuid = self._run(job)
job.job_uuid = uuid
job.start_time = datetime.now() job.start_time = datetime.now()
job.status = 'RUN' job.status = 'RUN'
job.save() job.save()
...@@ -52,8 +51,7 @@ class Service: ...@@ -52,8 +51,7 @@ class Service:
def restart_job(self, job): def restart_job(self, job):
job = Job.objects.get(pk=job) job = Job.objects.get(pk=job)
uuid = self.api.schedule('exa', job.spider.sp_name, query=job.query) job.job_uuid = self._run(job)
job.job_uuid = uuid
job.start_time = datetime.now() job.start_time = datetime.now()
job.end_time = None job.end_time = None
job.status = 'RUN' job.status = 'RUN'
...@@ -66,4 +64,6 @@ class Service: ...@@ -66,4 +64,6 @@ class Service:
response = urlopen(url) response = urlopen(url)
return response.read() return response.read()
def _run(self, job):
return self.api.schedule('exa', job.spider.sp_name, query=job.query)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment