Skip to content

Commit

Permalink
populate MetaJob from job (scrapinghub#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongkuo Ma committed Oct 25, 2019
1 parent a472d72 commit f173677
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/varanus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ def __init__(self, job: dict):
self.metadata = job or {}
self.__dict__.update(self.metadata)

def populate_from_job(self, job):
self.items = job.items.stats()['totals']['input_values']
self.pages = job.requests.stats()['totals']['input_values']
self.logs = job.logs.stats()['totals']['input_values']


class Job(MetaJob):

Expand All @@ -118,6 +123,7 @@ def __init__(self, project, key=None, defaults=None, data=None):
except StopIteration:
pass
self.metajob = MetaJob(dict(metadata))
self.metajob.populate_from_job(data)
self.__dict__.update(self.metajob.__dict__)
for key in defaults:
setattr(self, key, defaults[key])
Expand Down

0 comments on commit f173677

Please sign in to comment.