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.
- organizations_local/organizations_local.py +58 -35
- {organizations_local-0.0.47.dist-info → organizations_local-0.0.49.dist-info}/METADATA +1 -2
- organizations_local-0.0.49.dist-info/RECORD +7 -0
- {organizations_local-0.0.47.dist-info → organizations_local-0.0.49.dist-info}/WHEEL +1 -1
- organizations_local-0.0.47.dist-info/RECORD +0 -7
- {organizations_local-0.0.47.dist-info → organizations_local-0.0.49.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from database_mysql_local.generic_crud_ml import GenericCRUDML
|
|
2
|
-
from database_mysql_local.
|
|
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(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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,
|
|
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(
|
|
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,
|
|
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(
|
|
133
|
-
|
|
134
|
-
|
|
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,
|
|
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,
|
|
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],
|
|
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
|
|
158
|
-
|
|
159
|
-
|
|
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')
|
|
166
|
-
|
|
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],
|
|
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,
|
|
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
|
-
|
|
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",
|
|
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",
|
|
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",
|
|
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, *,
|
|
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.
|
|
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,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,,
|
|
File without changes
|