Rename all tables/models for Harvest "cache"

make this more explicit, for better naming convention
This commit is contained in:
Lance Edgar 2023-10-04 15:54:52 -05:00
parent 509405cb34
commit aa87ce57be
7 changed files with 324 additions and 88 deletions

View file

@ -37,20 +37,20 @@ log = logging.getLogger(__name__)
# harvest cache models
##############################
class HarvestUserImporter(ToRattail):
model_class = model.HarvestUser
class HarvestCacheUserImporter(ToRattail):
model_class = model.HarvestCacheUser
class HarvestClientImporter(ToRattail):
model_class = model.HarvestClient
class HarvestCacheClientImporter(ToRattail):
model_class = model.HarvestCacheClient
class HarvestProjectImporter(ToRattail):
model_class = model.HarvestProject
class HarvestCacheProjectImporter(ToRattail):
model_class = model.HarvestCacheProject
class HarvestTaskImporter(ToRattail):
model_class = model.HarvestTask
class HarvestCacheTaskImporter(ToRattail):
model_class = model.HarvestCacheTask
class HarvestTimeEntryImporter(ToRattail):
model_class = model.HarvestTimeEntry
class HarvestCacheTimeEntryImporter(ToRattail):
model_class = model.HarvestCacheTimeEntry
# flags to auto-create records for "unknown" references
auto_create_unknown_project = True
@ -59,12 +59,12 @@ class HarvestTimeEntryImporter(ToRattail):
warn_for_unknown_project = True
def setup(self):
super(HarvestTimeEntryImporter, self).setup()
super().setup()
model = self.model
if 'project_id' in self.fields:
self.harvest_projects_by_id = self.app.cache_model(
self.session, model.HarvestProject, key='id')
self.session, model.HarvestCacheProject, key='id')
def cache_query(self):
query = super().cache_query()
@ -81,12 +81,12 @@ class HarvestTimeEntryImporter(ToRattail):
return self.harvest_projects_by_id.get(project_id)
model = self.model
return self.session.query(model.HarvestProject)\
.filter(model.HarvestProject.id == project_id)\
return self.session.query(model.HarvestCacheProject)\
.filter(model.HarvestCacheProject.id == project_id)\
.first()
def update_object(self, entry, data, local_data=None):
entry = super(HarvestTimeEntryImporter, self).update_object(entry, data, local_data)
entry = super().update_object(entry, data, local_data)
model = self.model
if 'project_id' in self.fields:
@ -97,7 +97,7 @@ class HarvestTimeEntryImporter(ToRattail):
logger("unknown project id %s for time entry id %s: %s",
project_id, entry.id, entry)
if self.auto_create_unknown_project:
project = model.HarvestProject()
project = model.HarvestCacheProject()
project.id = project_id
project.name = "(unknown)"
self.session.add(project)