Avoid entries w/ timer still running when exporting to Harvest

i.e. ignore entries on Harvest, which have timer running
This commit is contained in:
Lance Edgar 2022-02-17 07:39:29 -06:00
parent e79686b5b7
commit d8e9714771

View file

@ -60,14 +60,19 @@ class TimeEntryImporter(ToHarvest):
Fetch existing time entries from Harvest.
"""
cache = {}
# TODO: we try to avoid entries w/ timer still running here,
# but for some reason they still come back, so double-check
entries = self.webapi.get_time_entries(**{'from': self.start_date,
'to': self.end_date})
'to': self.end_date,
'is_running': False})
for entry in entries:
data = self.normalize_local_object(entry)
if data:
normal = self.normalize_cache_object(entry, data)
key = self.get_cache_key(entry, normal)
cache[key] = normal
# double-check here
if not entry['is_running']:
data = self.normalize_local_object(entry)
if data:
normal = self.normalize_cache_object(entry, data)
key = self.get_cache_key(entry, normal)
cache[key] = normal
return cache
def normalize_local_object(self, entry):