organizations-local 0.0.47__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.
@@ -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
@@ -45,7 +45,7 @@ DEFAULT_NOT_DELETED_ML_VIEW_NAME = "organization_ml_not_deleted_view"
45
45
  # "start_timestamp",
46
46
  # "end_timestamp",
47
47
  # "main_group_id"
48
- #
48
+ #
49
49
  # organization_ml_table fields:
50
50
  # "organization_ml_id",
51
51
  # "organization_id",
@@ -95,26 +95,33 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
95
95
  return organization_id, organization_ml_id
96
96
 
97
97
  def upsert_organization(self, organization_dict: dict, order_by: str = None) -> dict:
98
- lang_code = LangCode.detect_lang_code_restricted(text=organization_dict.get('title'),
99
- #TODO the lang code can be in the organization_dict or in the UserContext, I'm not sure English as default is correct
100
- default_lang_code=LangCode.ENGLISH)
101
- organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
98
+ lang_code = LangCode.detect_lang_code_restricted(
99
+ text=organization_dict.get('title'),
100
+ # TODO the lang code can be in the organization_dict or in the UserContext, I'm not sure English as default is correct
101
+ default_lang_code=LangCode.ENGLISH)
102
+ organization_ml_dict = self._clean_organization_ml_dict(
103
+ organization_dict)
102
104
  organization_dict = self._clean_organization_dict(organization_dict)
103
105
 
104
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?
105
107
  if "(" and ")" in organization_dict.get('title', ''):
106
- organization_id, organzation_ml_ids_list = GenericCRUDML.upsert_value_with_abbreviations(
107
- self, data_ml_dict=organization_ml_dict, lang_code=lang_code,
108
- data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME, table_name=DEFAULT_TABLE_NAME,
109
- ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
108
+ organization_id, organzation_ml_ids_list =\
109
+ GenericCRUDML.upsert_value_with_abbreviations(
110
+ self, data_ml_dict=organization_ml_dict,
111
+ lang_code=lang_code,
112
+ data_dict=organization_dict,
113
+ schema_name=DEFAULT_SCHEMA_NAME,
114
+ table_name=DEFAULT_TABLE_NAME,
115
+ ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
110
116
  else:
111
117
  organization_id, organzation_ml_id = GenericCRUDML.upsert_value(
112
118
  self, data_ml_dict=organization_ml_dict, lang_code=lang_code,
113
- data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME, table_name=DEFAULT_TABLE_NAME,
119
+ data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME,
120
+ table_name=DEFAULT_TABLE_NAME,
114
121
  ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
115
122
  organzation_ml_ids_list = [organzation_ml_id]
116
123
 
117
- #TODO upsert_result_dict
124
+ # TODO upsert_result_dict
118
125
  upsert_information = {
119
126
  "organization_id": organization_id,
120
127
  "organization_ml_ids_list": organzation_ml_ids_list
@@ -124,23 +131,28 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
124
131
 
125
132
  def update_organization(self, *, organization_id: int, organization_ml_id: int, organization_dict: dict) -> None:
126
133
  # TODO: should we have such a method in CRUD ML? Same for delete
127
- organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
134
+ organization_ml_dict = self._clean_organization_ml_dict(
135
+ organization_dict)
128
136
  organization_ml_dict["organization_id"] = organization_id
129
137
  organization_dict = self._clean_organization_dict(organization_dict)
130
- GenericCRUDML.update_by_column_and_value(self, column_value=organization_id,
138
+ GenericCRUDML.update_by_column_and_value(self,
139
+ column_value=organization_id,
131
140
  data_dict=organization_dict)
132
- GenericCRUDML.update_by_column_and_value(self, table_name="organization_ml_table",
133
- column_value=organization_ml_id, data_dict=organization_ml_dict,
134
- column_name="organization_ml_id")
141
+ GenericCRUDML.update_by_column_and_value(
142
+ self, table_name="organization_ml_table",
143
+ column_value=organization_ml_id, data_dict=organization_ml_dict,
144
+ column_name="organization_ml_id")
135
145
 
136
146
  def get_organization_dict_by_organization_id(
137
- self, *, organization_id: int, organization_ml_id: int = None, view_table_name: str = None) -> dict:
147
+ self, *, organization_id: int, organization_ml_id: int = None,
148
+ view_table_name: str = None) -> dict:
138
149
  view_table_name = view_table_name or self.default_view_table_name
139
150
  organization_ml_dict = {}
140
151
  if organization_ml_id:
141
152
  organization_ml_dict = self.select_one_dict_by_column_and_value(
142
153
  view_table_name="organization_ml_view",
143
- column_value=organization_ml_id, column_name="organization_ml_id")
154
+ column_value=organization_ml_id,
155
+ column_name="organization_ml_id")
144
156
  organization_dict = self.select_one_dict_by_column_and_value(
145
157
  view_table_name=view_table_name,
146
158
  column_value=organization_id, column_name="organization_id")
@@ -148,28 +160,35 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
148
160
  return {**organization_dict, **organization_ml_dict}
149
161
 
150
162
  def get_organizations_names_list_by_organizations_ids(
151
- self, *, organizations_ids_list: list[int], lang_codes_list: list[LangCode] = None,
163
+ self, *, organizations_ids_list: list[int],
164
+ lang_codes_list: list[LangCode] = None,
152
165
  view_table_name: str = None) -> list[str]:
153
166
  lang_codes_list = lang_codes_list or [LangCode.ENGLISH]
154
167
  view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
155
168
  organizations_names_list = []
156
169
  for organization_id in organizations_ids_list:
157
- organization_name_dicts = self.select_multi_dict_by_column_and_value(
158
- view_table_name=view_table_name, select_clause_value="title, lang_code",
159
- column_name="organization_id", column_value=organization_id)
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)
160
176
 
161
177
  # filter by lang_codes_list
162
178
  # TODO: improve performance
163
179
  for lang_code in lang_codes_list:
164
180
  for organization_name_dict in organization_name_dicts:
165
- if organization_name_dict.get('lang_code') == lang_code.value:
166
- organizations_names_list.append(organization_name_dict.get('title'))
181
+ if organization_name_dict.get('lang_code') ==\
182
+ lang_code.value:
183
+ organizations_names_list.append(
184
+ organization_name_dict.get('title'))
167
185
 
168
186
  return organizations_names_list
169
187
 
170
188
  # Edited by Tal Goodman on 12.7.24
171
189
  def get_organizations_ids_and_names_list_by_organizations_ids(
172
- self, *, organizations_ids_list: list[int], lang_codes_list: list[LangCode] = None,
190
+ self, *, organizations_ids_list: list[int],
191
+ lang_codes_list: list[LangCode] = None,
173
192
  view_table_name: str = None) -> list[tuple[int, str]]:
174
193
  lang_codes_list = lang_codes_list or [LangCode.ENGLISH]
175
194
  view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
@@ -178,32 +197,36 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
178
197
  placeholders = ', '.join(['%s'] * len(organizations_ids_list))
179
198
  where_clause_value = f"organization_id in ({placeholders})"
180
199
  organizations_ids_and_names_list = self.select_multi_tuple_by_where(
181
- view_table_name=view_table_name, select_clause_value=select_clause_value,
200
+ view_table_name=view_table_name,
201
+ select_clause_value=select_clause_value,
182
202
  where=where_clause_value, params=organizations_ids_list
183
203
  )
184
204
  return organizations_ids_and_names_list
185
205
 
186
-
187
- def delete_by_organization_id(self, organization_id: int, organization_ml_id: int = None) -> None:
206
+ def delete_by_organization_id(self, organization_id: int,
207
+ organization_ml_id: int = None) -> None:
188
208
  # Delete from organization_table
189
209
  self.delete_by_column_and_value(table_name="organization_table",
190
- column_name="organization_id", column_value=organization_id)
210
+ column_name="organization_id",
211
+ column_value=organization_id)
191
212
 
192
213
  # Delete from organization_ml_table
193
214
  if organization_ml_id:
194
215
  self.delete_by_column_and_value(table_name="organization_ml_table",
195
- column_name="organization_ml_id", column_value=organization_ml_id)
196
-
216
+ column_name="organization_ml_id",
217
+ column_value=organization_ml_id)
197
218
 
198
219
  def get_test_organization_id(self) -> int:
199
220
  test_organization_id = self.get_test_entity_id(
200
- entity_name="organization", insert_function=self.insert_organization)
221
+ entity_name="organization",
222
+ insert_function=self.insert_organization)
201
223
  return test_organization_id
202
224
 
203
-
204
225
  # TODO Add support of multiple organizations per contact
205
226
  # Was def get_update_status(self, *, last_modified_timestamp: str, main_profile_id: int) -> UpdateStatus:
206
- def get_update_status_and_information_list(self, *, last_modified_timestamp: str, main_profile_id: int or None) -> 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]:
207
230
  if main_profile_id is None:
208
231
  update_status_and_information_list = [{"update_status": UpdateStatus.UPDATE_CIRCLEZ}]
209
232
  return update_status_and_information_list
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: organizations-local
3
- Version: 0.0.47
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=pxyAMmv4BFCfzyDsF92vImLdazA7_0ecKyVmOR9peEE,900
3
- organizations_local/organizations_local.py,sha256=YGaFtJ_qA4CCHr20b8NqSNz9kVQrs6Thovr3pUn97JY,13318
4
- organizations_local-0.0.47.dist-info/METADATA,sha256=kSWLWIDxE_BPhWh3Dj_B4mR4ZW91RsMhEWRRjYuRFwk,822
5
- organizations_local-0.0.47.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
6
- organizations_local-0.0.47.dist-info/top_level.txt,sha256=Y8wRcm3jFTyMdysBub_P8iqX1VOMS0ohUxA1GQdngFU,20
7
- organizations_local-0.0.47.dist-info/RECORD,,