Skip to content

Commit

Permalink
fix: bug fix for support qbd (minor fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed Aug 5, 2024
1 parent e3bfbd2 commit ecccf31
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions apps/mappings/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,13 @@ def sync_projects(self, source_type: str):

for projects in projects_generator:
for project in projects.get('data'):
if project['sub_project']:
project['name'] = '{0} / {1}'.format(project['name'], project['sub_project'])
if project['name'] not in existing_projects:
source_attributes.append({
'attribute_type': source_type,
'value': project['name'],
'source_id': project['id']
})

project['name'] = '{0} / {1}'.format(project['name'], project['sub_project'])
if project['name'] not in existing_projects:
source_attributes.append({
'attribute_type': source_type,
'value': project['name'],
'source_id': project['id']
})

if source_attributes:
QBDMapping.update_or_create_mapping_objects(source_attributes, self.workspace_id)
Expand All @@ -139,6 +137,7 @@ def sync_cost_center(self, source_type: str):
query = {
'order': 'updated_at.desc'
}

cost_center_generator = self.platform.v1beta.admin.cost_centers.list_all(query)
existing_cost_centers = QBDMapping.objects.filter(workspace_id=self.workspace_id, attribute_type=source_type)

Expand All @@ -147,12 +146,12 @@ def sync_cost_center(self, source_type: str):
for cost_centers in cost_center_generator:
for cost_center in cost_centers.get('data'):
if cost_center not in existing_cost_centers:
print(cost_center, 'anish268807')
source_attributes.append({
'attribute_type': source_type,
'value': cost_center,
'source_id': cost_center
'value': cost_center['name'],
'source_id': cost_center['id']
})


if source_attributes:
QBDMapping.update_or_create_mapping_objects(source_attributes, self.workspace_id)

0 comments on commit ecccf31

Please sign in to comment.