organizations-local 0.0.48__py3-none-any.whl → 0.0.49__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,16 +4,16 @@ ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID = 286
4
4
  ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME = "organization-local-python-package"
5
5
  DEVELOPER_EMAIL = "tal.g@circ.zone"
6
6
  ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT = {
7
- "component_id": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
8
- "component_name": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
9
- "component_category": LoggerComponentEnum.ComponentCategory.Code.value,
10
- "developer_email": DEVELOPER_EMAIL,
7
+ 'component_id': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
8
+ 'component_name': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
9
+ 'component_category': LoggerComponentEnum.ComponentCategory.Code.value,
10
+ 'developer_email': DEVELOPER_EMAIL
11
11
  }
12
12
 
13
13
  ORGANIZATIONS_PYTHON_PACKAGE_TEST_LOGGER_OBJECT = {
14
- "component_id": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
15
- "component_name": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
16
- "component_category": LoggerComponentEnum.ComponentCategory.Unit_Test.value,
17
- "testing_framework": LoggerComponentEnum.testingFramework.pytest.value,
18
- "developer_email": DEVELOPER_EMAIL,
14
+ 'component_id': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
15
+ 'component_name': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
16
+ 'component_category': LoggerComponentEnum.ComponentCategory.Unit_Test.value,
17
+ 'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
18
+ 'developer_email': DEVELOPER_EMAIL
19
19
  }
@@ -1,5 +1,5 @@
1
1
  from database_mysql_local.generic_crud_ml import GenericCRUDML
2
- from database_mysql_local.constants import UpdateStatus
2
+ from database_mysql_local.constants_src import UpdateStatus
3
3
  from database_mysql_local.sync_conflict_resolution import SyncConflictResolution
4
4
  from language_remote.lang_code import LangCode
5
5
  from logger_local.MetaLogger import MetaLogger
@@ -57,49 +57,27 @@ DEFAULT_NOT_DELETED_ML_VIEW_NAME = "organization_ml_not_deleted_view"
57
57
  # "description"
58
58
 
59
59
 
60
- class OrganizationsLocal(
61
- GenericCRUDML,
62
- metaclass=MetaLogger,
63
- object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT,
64
- ):
60
+ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
61
+ object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT):
65
62
  def __init__(self, is_test_data=False) -> None:
66
- GenericCRUDML.__init__(
67
- self,
68
- default_schema_name=DEFAULT_SCHEMA_NAME,
69
- default_table_name=DEFAULT_TABLE_NAME,
70
- default_column_name=DEFAULT_ID_COLUMN_NAME,
71
- is_test_data=is_test_data,
72
- )
63
+ GenericCRUDML.__init__(self, default_schema_name=DEFAULT_SCHEMA_NAME,
64
+ default_table_name=DEFAULT_TABLE_NAME,
65
+ default_column_name=DEFAULT_ID_COLUMN_NAME,
66
+ is_test_data=is_test_data)
73
67
  self.default_view_table_name = DEFAULT_VIEW_NAME
74
68
 
75
69
  @staticmethod
76
70
  def _clean_organization_dict(organization_dict: dict) -> dict:
77
- columns = (
78
- "name",
79
- "is_approved",
80
- "is_main",
81
- "point",
82
- "location_id",
83
- "profile_id",
84
- "parent_organization_id",
85
- "non_members_visibility_scope_id",
86
- "members_visibility_scope_id",
87
- "Non_members_visibility_profile_id",
88
- "main_group_id",
89
- )
71
+ columns = ("name", "is_approved", "is_main", "point", "location_id", "profile_id", "parent_organization_id",
72
+ "non_members_visibility_scope_id", "members_visibility_scope_id",
73
+ "Non_members_visibility_profile_id", "main_group_id")
90
74
  organization_dict = {key: organization_dict.get(key) for key in columns}
91
75
  return organization_dict
92
76
 
93
77
  @staticmethod
94
78
  def _clean_organization_ml_dict(organization_dict: dict) -> dict:
95
- columns = (
96
- "lang_code",
97
- "is_main",
98
- "title",
99
- "is_title_approved",
100
- "is_description_approved",
101
- "description",
102
- )
79
+ columns = ("lang_code", "is_main", "title", "is_title_approved",
80
+ "is_description_approved", "description")
103
81
  organization_ml_dict = {key: organization_dict.get(key) for key in columns}
104
82
  return organization_ml_dict
105
83
 
@@ -111,201 +89,153 @@ class OrganizationsLocal(
111
89
  organization_dict = self._clean_organization_dict(organization_dict)
112
90
  organization_id = GenericCRUDML.insert(self, data_dict=organization_dict)
113
91
  organization_ml_data_dict["organization_id"] = organization_id
114
- organization_ml_id = GenericCRUDML.insert(
115
- self,
116
- table_name="organization_ml_table",
117
- data_dict=organization_ml_data_dict,
118
- )
92
+ organization_ml_id = GenericCRUDML.insert(self, table_name="organization_ml_table",
93
+ data_dict=organization_ml_data_dict)
119
94
 
120
95
  return organization_id, organization_ml_id
121
96
 
122
- def upsert_organization(
123
- self, organization_dict: dict, order_by: str = None
124
- ) -> dict:
97
+ def upsert_organization(self, organization_dict: dict, order_by: str = None) -> dict:
125
98
  lang_code = LangCode.detect_lang_code_restricted(
126
- text=organization_dict.get("title"),
99
+ text=organization_dict.get('title'),
127
100
  # TODO the lang code can be in the organization_dict or in the UserContext, I'm not sure English as default is correct
128
- default_lang_code=LangCode.ENGLISH,
129
- )
130
- organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
101
+ default_lang_code=LangCode.ENGLISH)
102
+ organization_ml_dict = self._clean_organization_ml_dict(
103
+ organization_dict)
131
104
  organization_dict = self._clean_organization_dict(organization_dict)
132
105
 
133
- # TODO Why do we need to do this if outside of GenericCrud in every entity, can we move this "if" into the Generic Crud method? Can we avoid two methods? The parameters of the two methods are the same? # noqa
134
- if "(" and ")" in organization_dict.get("title", ""):
135
- organization_id, organzation_ml_ids_list = (
106
+ # TODO Why do we need to do this if outside of GenericCrud in every entity, can we move this "if" into the Generic Crud method? Can we avoid two methods? The parameters of the two methods are the same?
107
+ if "(" and ")" in organization_dict.get('title', ''):
108
+ organization_id, organzation_ml_ids_list =\
136
109
  GenericCRUDML.upsert_value_with_abbreviations(
137
- self,
138
- data_ml_dict=organization_ml_dict,
110
+ self, data_ml_dict=organization_ml_dict,
139
111
  lang_code=lang_code,
140
112
  data_dict=organization_dict,
141
113
  schema_name=DEFAULT_SCHEMA_NAME,
142
114
  table_name=DEFAULT_TABLE_NAME,
143
- ml_table_name=DEFAULT_ML_TABLE_NAME,
144
- order_by=order_by,
145
- )
146
- )
115
+ ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
147
116
  else:
148
117
  organization_id, organzation_ml_id = GenericCRUDML.upsert_value(
149
- self,
150
- data_ml_dict=organization_ml_dict,
151
- lang_code=lang_code,
152
- data_dict=organization_dict,
153
- schema_name=DEFAULT_SCHEMA_NAME,
118
+ self, data_ml_dict=organization_ml_dict, lang_code=lang_code,
119
+ data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME,
154
120
  table_name=DEFAULT_TABLE_NAME,
155
- ml_table_name=DEFAULT_ML_TABLE_NAME,
156
- order_by=order_by,
157
- )
121
+ ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
158
122
  organzation_ml_ids_list = [organzation_ml_id]
159
123
 
160
124
  # TODO upsert_result_dict
161
125
  upsert_information = {
162
126
  "organization_id": organization_id,
163
- "organization_ml_ids_list": organzation_ml_ids_list,
127
+ "organization_ml_ids_list": organzation_ml_ids_list
164
128
  }
165
129
 
166
130
  return upsert_information
167
131
 
168
- def update_organization(
169
- self, *, organization_id: int, organization_ml_id: int, organization_dict: dict
170
- ) -> None:
132
+ def update_organization(self, *, organization_id: int, organization_ml_id: int, organization_dict: dict) -> None:
171
133
  # TODO: should we have such a method in CRUD ML? Same for delete
172
- organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
134
+ organization_ml_dict = self._clean_organization_ml_dict(
135
+ organization_dict)
173
136
  organization_ml_dict["organization_id"] = organization_id
174
137
  organization_dict = self._clean_organization_dict(organization_dict)
138
+ GenericCRUDML.update_by_column_and_value(self,
139
+ column_value=organization_id,
140
+ data_dict=organization_dict)
175
141
  GenericCRUDML.update_by_column_and_value(
176
- self, column_value=organization_id, data_dict=organization_dict
177
- )
178
- GenericCRUDML.update_by_column_and_value(
179
- self,
180
- table_name="organization_ml_table",
181
- column_value=organization_ml_id,
182
- data_dict=organization_ml_dict,
183
- column_name="organization_ml_id",
184
- )
142
+ self, table_name="organization_ml_table",
143
+ column_value=organization_ml_id, data_dict=organization_ml_dict,
144
+ column_name="organization_ml_id")
185
145
 
186
146
  def get_organization_dict_by_organization_id(
187
- self,
188
- *,
189
- organization_id: int,
190
- organization_ml_id: int = None,
191
- view_table_name: str = None,
192
- ) -> dict:
147
+ self, *, organization_id: int, organization_ml_id: int = None,
148
+ view_table_name: str = None) -> dict:
193
149
  view_table_name = view_table_name or self.default_view_table_name
194
150
  organization_ml_dict = {}
195
151
  if organization_ml_id:
196
152
  organization_ml_dict = self.select_one_dict_by_column_and_value(
197
153
  view_table_name="organization_ml_view",
198
154
  column_value=organization_ml_id,
199
- column_name="organization_ml_id",
200
- )
155
+ column_name="organization_ml_id")
201
156
  organization_dict = self.select_one_dict_by_column_and_value(
202
157
  view_table_name=view_table_name,
203
- column_value=organization_id,
204
- column_name="organization_id",
205
- )
158
+ column_value=organization_id, column_name="organization_id")
206
159
 
207
160
  return {**organization_dict, **organization_ml_dict}
208
161
 
209
162
  def get_organizations_names_list_by_organizations_ids(
210
- self,
211
- *,
212
- organizations_ids_list: list[int],
213
- lang_codes_list: list[LangCode] = None,
214
- view_table_name: str = None,
215
- ) -> list[str]:
163
+ self, *, organizations_ids_list: list[int],
164
+ lang_codes_list: list[LangCode] = None,
165
+ view_table_name: str = None) -> list[str]:
216
166
  lang_codes_list = lang_codes_list or [LangCode.ENGLISH]
217
167
  view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
218
168
  organizations_names_list = []
219
169
  for organization_id in organizations_ids_list:
220
- organization_name_dicts = self.select_multi_dict_by_column_and_value(
221
- view_table_name=view_table_name,
222
- select_clause_value="title, lang_code",
223
- column_name="organization_id",
224
- column_value=organization_id,
225
- )
170
+ organization_name_dicts =\
171
+ self.select_multi_dict_by_column_and_value(
172
+ view_table_name=view_table_name,
173
+ select_clause_value="title, lang_code",
174
+ column_name="organization_id",
175
+ column_value=organization_id)
226
176
 
227
177
  # filter by lang_codes_list
228
178
  # TODO: improve performance
229
179
  for lang_code in lang_codes_list:
230
180
  for organization_name_dict in organization_name_dicts:
231
- if organization_name_dict.get("lang_code") == lang_code.value:
181
+ if organization_name_dict.get('lang_code') ==\
182
+ lang_code.value:
232
183
  organizations_names_list.append(
233
- organization_name_dict.get("title")
234
- )
184
+ organization_name_dict.get('title'))
235
185
 
236
186
  return organizations_names_list
237
187
 
238
188
  # Edited by Tal Goodman on 12.7.24
239
189
  def get_organizations_ids_and_names_list_by_organizations_ids(
240
- self,
241
- *,
242
- organizations_ids_list: list[int],
243
- lang_codes_list: list[LangCode] = None,
244
- view_table_name: str = None,
245
- ) -> list[tuple[int, str]]:
246
- if not organizations_ids_list:
247
- return []
248
-
190
+ self, *, organizations_ids_list: list[int],
191
+ lang_codes_list: list[LangCode] = None,
192
+ view_table_name: str = None) -> list[tuple[int, str]]:
249
193
  lang_codes_list = lang_codes_list or [LangCode.ENGLISH]
250
194
  view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
251
195
  organizations_ids_and_names_list = []
252
196
  select_clause_value = "organization_id, title"
253
- placeholders = ", ".join(["%s"] * len(organizations_ids_list))
197
+ placeholders = ', '.join(['%s'] * len(organizations_ids_list))
254
198
  where_clause_value = f"organization_id in ({placeholders})"
255
199
  organizations_ids_and_names_list = self.select_multi_tuple_by_where(
256
200
  view_table_name=view_table_name,
257
201
  select_clause_value=select_clause_value,
258
- where=where_clause_value,
259
- params=organizations_ids_list,
202
+ where=where_clause_value, params=organizations_ids_list
260
203
  )
261
204
  return organizations_ids_and_names_list
262
205
 
263
- def delete_by_organization_id(
264
- self, organization_id: int, organization_ml_id: int = None
265
- ) -> None:
206
+ def delete_by_organization_id(self, organization_id: int,
207
+ organization_ml_id: int = None) -> None:
266
208
  # Delete from organization_table
267
- self.delete_by_column_and_value(
268
- table_name="organization_table",
269
- column_name="organization_id",
270
- column_value=organization_id,
271
- )
209
+ self.delete_by_column_and_value(table_name="organization_table",
210
+ column_name="organization_id",
211
+ column_value=organization_id)
272
212
 
273
213
  # Delete from organization_ml_table
274
214
  if organization_ml_id:
275
- self.delete_by_column_and_value(
276
- table_name="organization_ml_table",
277
- column_name="organization_ml_id",
278
- column_value=organization_ml_id,
279
- )
215
+ self.delete_by_column_and_value(table_name="organization_ml_table",
216
+ column_name="organization_ml_id",
217
+ column_value=organization_ml_id)
280
218
 
281
219
  def get_test_organization_id(self) -> int:
282
220
  test_organization_id = self.get_test_entity_id(
283
- entity_name="organization", insert_function=self.insert_organization
284
- )
221
+ entity_name="organization",
222
+ insert_function=self.insert_organization)
285
223
  return test_organization_id
286
224
 
287
225
  # TODO Add support of multiple organizations per contact
288
226
  # Was def get_update_status(self, *, last_modified_timestamp: str, main_profile_id: int) -> UpdateStatus:
289
- def get_update_status_and_information_list(
290
- self, *, last_modified_timestamp: str, main_profile_id: int | None
291
- ) -> list[dict]:
227
+ def get_update_status_and_information_list(self, *,
228
+ last_modified_timestamp: str,
229
+ main_profile_id: int or None) -> list[dict]:
292
230
  if main_profile_id is None:
293
- update_status_and_information_list = [
294
- {"update_status": UpdateStatus.UPDATE_CIRCLEZ}
295
- ]
231
+ update_status_and_information_list = [{"update_status": UpdateStatus.UPDATE_CIRCLEZ}]
296
232
  return update_status_and_information_list
297
233
  sync_conflict_resolution = SyncConflictResolution()
298
234
  # TODO: Shall we also check update_timestamp in organization_table to see if the name was changed?
299
- update_status_and_information_list: list[dict] = (
300
- sync_conflict_resolution.get_update_status_and_information_list_by_where(
301
- schema_name="organization_profile",
302
- view_table_name="organization_profile_view",
303
- where="profile_id = %s",
304
- params=(main_profile_id,),
305
- local_last_modified_column_name="updated_timestamp",
306
- remote_last_modified_timestamp=last_modified_timestamp,
307
- )
308
- )
235
+ update_status_and_information_list: list[dict] = sync_conflict_resolution.get_update_status_and_information_list_by_where(
236
+ schema_name="organization_profile", view_table_name="organization_profile_view",
237
+ where="profile_id = %s", params=(main_profile_id,), local_last_modified_column_name="updated_timestamp",
238
+ remote_last_modified_timestamp=last_modified_timestamp)
309
239
  # Add organization_names to update_status_and_information_list
310
240
  # TODO: Can we use a list of only the updated organization since the last sync?
311
241
  organizations_ids_list = []
@@ -314,36 +244,28 @@ class OrganizationsLocal(
314
244
  if organization_id is not None:
315
245
  organizations_ids_list.append(organization_id)
316
246
 
317
- organizations_ids_and_names_list = (
318
- self.get_organizations_ids_and_names_list_by_organizations_ids(
319
- organizations_ids_list=organizations_ids_list,
320
- view_table_name="organization_ml_view",
321
- )
322
- )
247
+ organizations_ids_and_names_list = self.get_organizations_ids_and_names_list_by_organizations_ids(
248
+ organizations_ids_list=organizations_ids_list,
249
+ view_table_name="organization_ml_view")
323
250
 
324
251
  # Convert organizations_ids_and_names_list to a dictionary
325
- organizations_ids_and_names_dict = {
326
- item[0]: item[1] for item in organizations_ids_and_names_list
327
- }
252
+ organizations_ids_and_names_dict = {item[0]: item[1] for item in organizations_ids_and_names_list}
328
253
 
329
254
  for update_status_and_information in update_status_and_information_list:
330
255
  organization_id = update_status_and_information.get("organization_id")
331
256
  if organization_id is not None:
332
- update_status_and_information["organization_name"] = (
333
- organizations_ids_and_names_dict.get(organization_id)
334
- )
335
-
257
+ update_status_and_information["organization_name"] = organizations_ids_and_names_dict.get(organization_id)
258
+
336
259
  return update_status_and_information_list
337
260
 
338
- def get_organization_name_by_organization_identifier(
339
- self, organization_identifier: str
340
- ) -> str | None:
341
- organization_name = self.select_one_value_by_column_and_value(
342
- select_clause_value="name",
343
- schema_name="organization",
344
- view_table_name="organization_view",
345
- column_name="identifier",
346
- column_value=organization_identifier,
347
- )
348
261
 
349
- return organization_name
262
+ def get_organization_name_by_organization_identifier(self, organization_identifier: str) -> str or None:
263
+ organization_name=self.select_one_value_by_column_and_value(
264
+ select_clause_value="name",
265
+ schema_name="organization",
266
+ view_table_name="organization_view",
267
+ column_name="identifier",
268
+ column_value=organization_identifier,
269
+ )
270
+
271
+ return organization_name
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: organizations-local
3
- Version: 0.0.48
3
+ Version: 0.0.49
4
4
  Summary: PyPI Package for Circles organizations-local Python
5
5
  Home-page: https://github.com/circles-zone/organizations-local-python-package
6
6
  Author: Circles
7
7
  Author-email: info@circlez.ai
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: Other/Proprietary License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Description-Content-Type: text/markdown
12
11
  Requires-Dist: database-mysql-local>=0.0.290
@@ -0,0 +1,7 @@
1
+ organizations_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ organizations_local/organizations_constants.py,sha256=pxyAMmv4BFCfzyDsF92vImLdazA7_0ecKyVmOR9peEE,900
3
+ organizations_local/organizations_local.py,sha256=I2G3_8zFkBIoE-4PbPB83SZhHN2Gx9v2pjiFwSmI2b4,13769
4
+ organizations_local-0.0.49.dist-info/METADATA,sha256=PAI7FwUaP8DiMLAxOG_JU-rIUfogjme6AYA1Gv6SLv0,773
5
+ organizations_local-0.0.49.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
6
+ organizations_local-0.0.49.dist-info/top_level.txt,sha256=Y8wRcm3jFTyMdysBub_P8iqX1VOMS0ohUxA1GQdngFU,20
7
+ organizations_local-0.0.49.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- organizations_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- organizations_local/organizations_constants.py,sha256=mh_XncG0Q8-k_VUCHWVQRdlMXNnf_GCiCcL-rn7R3lw,902
3
- organizations_local/organizations_local.py,sha256=DYDrEElmPm9Pdn7-q4OkFYueYB5yjcyATXRLAO7d1yM,13904
4
- organizations_local-0.0.48.dist-info/METADATA,sha256=jB42bYpjsLRGlviQvbXdgZSEOJ_UeM9WxishIImtTXQ,822
5
- organizations_local-0.0.48.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
6
- organizations_local-0.0.48.dist-info/top_level.txt,sha256=Y8wRcm3jFTyMdysBub_P8iqX1VOMS0ohUxA1GQdngFU,20
7
- organizations_local-0.0.48.dist-info/RECORD,,