Fix (more) start/end date defaults for importers, per upstream changes

This commit is contained in:
Lance Edgar 2023-09-25 13:26:58 -05:00
parent 2f21e574ae
commit e58d843ee4
3 changed files with 22 additions and 9 deletions

View file

@ -226,8 +226,12 @@ class HarvestTimeEntryImporter(FromHarvest, rattail_harvest_importing.model.Harv
"""
def get_host_objects(self):
return self.webapi.get_time_entries(**{'from': self.start_date,
'to': self.end_date})
kw = {}
if self.start_date:
kw['from'] = self.start_date
if self.end_date:
kw['to'] = self.end_date
return self.webapi.get_time_entries(**kw)
def normalize_host_object(self, entry):
data = super(HarvestTimeEntryImporter, self).normalize_host_object(entry)

View file

@ -61,6 +61,11 @@ class HarvestTaskImporter(base.FromRattail, rattail_harvest_importing.model.Harv
class HarvestTimeEntryImporter(base.FromRattail, rattail_harvest_importing.model.HarvestTimeEntryImporter):
def query(self):
query = super(HarvestTimeEntryImporter, self).query()
return query.filter(self.model_class.spent_date >= self.start_date)\
.filter(self.model_class.spent_date <= self.end_date)
query = super().query()
if self.start_date:
query = query.filter(self.model_class.spent_date >= self.start_date)
if self.end_date:
query = query.filter(self.model_class.spent_date <= self.end_date)
return query