Skip to content

Commit 8c386d4

Browse files
committed
Fix custom field id handling
1 parent f0c38ee commit 8c386d4

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ def get_custom_field_name(
881881
@abstractmethod
882882
def get_custom_field_component_id(
883883
self,
884+
context: dict,
884885
field_id: int,
885886
entity: CustomFieldEntityEnum,
886887
parent: CustomFieldEntityEnum,

src/superannotate/lib/core/usecases/projects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def execute(self):
186186
)
187187
# timestamp: convert milliseconds to seconds
188188
component_id = self._service_provider.get_custom_field_component_id(
189+
context,
189190
field_id,
190191
entity=CustomFieldEntityEnum.PROJECT,
191192
parent=CustomFieldEntityEnum.TEAM,

src/superannotate/lib/infrastructure/controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def serialize_custom_fields(
9797
field_id = int(custom_field_name)
9898
try:
9999
component_id = service_provider.get_custom_field_component_id(
100-
field_id, entity=entity, parent=parent_entity
100+
context, field_id, entity=entity, parent=parent_entity
101101
)
102102
except AppException:
103103
# The component template can be deleted, but not from the entity, so it will be skipped.
@@ -155,7 +155,7 @@ def set_custom_field_value(
155155
_context, field_name, entity=entity, parent=parent_entity
156156
)
157157
component_id = self.service_provider.get_custom_field_component_id(
158-
template_id, entity=entity, parent=parent_entity
158+
_context, template_id, entity=entity, parent=parent_entity
159159
)
160160
# timestamp: convert seconds to milliseconds
161161
if component_id == CustomFieldType.DATE_PICKER.value and value is not None:

src/superannotate/lib/infrastructure/query_builder.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,28 @@ def __init__(
174174
self._parent = parent
175175
self._team_id = team_id
176176
self._project_id = project_id
177+
self._context = {"team_id": self._team_id, "project_id": self._project_id}
177178

178179
def _handle_custom_field_key(self, key) -> Tuple[str, str, Optional[str]]:
179-
context = {"team_id": self._team_id, "project_id": self._project_id}
180180
for custom_field in sorted(
181181
self._service_provider.list_custom_field_names(
182-
context, self._entity, parent=self._parent
182+
self._context, self._entity, parent=self._parent
183183
),
184184
key=len,
185185
reverse=True,
186186
):
187187
if custom_field in key:
188188
custom_field_id = self._service_provider.get_custom_field_id(
189-
context, custom_field, entity=self._entity, parent=self._parent
189+
self._context,
190+
custom_field,
191+
entity=self._entity,
192+
parent=self._parent,
190193
)
191194
component_id = self._service_provider.get_custom_field_component_id(
192-
custom_field_id, entity=self._entity, parent=self._parent
195+
self._context,
196+
custom_field_id,
197+
entity=self._entity,
198+
parent=self._parent,
193199
)
194200
key = key.replace(
195201
custom_field,
@@ -230,7 +236,10 @@ def _determine_condition_and_key(keys: List[str]) -> Tuple[OperatorEnum, str]:
230236
def _handle_special_fields(self, keys: List[str], val):
231237
if keys[0] == "custom_field":
232238
component_id = self._service_provider.get_custom_field_component_id(
233-
field_id=int(keys[1]), entity=self._entity, parent=self._parent
239+
self._context,
240+
field_id=int(keys[1]),
241+
entity=self._entity,
242+
parent=self._parent,
234243
)
235244
if component_id == CustomFieldType.DATE_PICKER.value and val is not None:
236245
try:

src/superannotate/lib/infrastructure/serviceprovider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ def get_custom_field_name(
125125

126126
def get_custom_field_component_id(
127127
self,
128+
context: EntityContext,
128129
field_id: int,
129130
entity: CustomFieldEntityEnum,
130131
parent: CustomFieldEntityEnum,
131132
) -> str:
132133
return self._cached_work_management_repository.get_custom_field_component_id(
133-
{"team_id": self.client.team_id}, field_id, entity=entity, parent=parent
134+
context, field_id, entity=entity, parent=parent
134135
)
135136

136137
def get_role_id(self, project: entities.ProjectEntity, role_name: str) -> int:

tests/integration/work_management/test_pause_resume_user_activity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def test_pause_and_resume_user_activity(self):
3636
scapegoat = [
3737
u for u in users if u["role"] == "Contributor" and u["state"] == "Confirmed"
3838
][0]
39+
import pdb
40+
pdb.set_trace()
3941
sa.add_contributors_to_project(self.PROJECT_NAME, [scapegoat["email"]], "QA")
4042
with self.assertLogs("sa", level="INFO") as cm:
4143
sa.pause_user_activity(pk=scapegoat["email"], projects=[self.PROJECT_NAME])

0 commit comments

Comments
 (0)