contact-person-profile-csv-imp-local 0.0.34__tar.gz → 0.0.36__tar.gz

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.
Files changed (13) hide show
  1. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/PKG-INFO +1 -1
  2. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +45 -43
  3. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local/src/contact_person_profile_csv_imp_local_constants.py +6 -0
  4. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +1 -1
  5. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/setup.py +1 -1
  6. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/README.md +0 -0
  7. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
  8. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
  9. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
  10. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local.egg-info/requires.txt +0 -0
  11. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
  12. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/pyproject.toml +0 -0
  13. {contact_person_profile_csv_imp_local-0.0.34 → contact_person_profile_csv_imp_local-0.0.36}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
5
5
  Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
6
6
  Author: Circles
@@ -46,12 +46,6 @@ CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID = 1
46
46
  DEFAULT_LOCATION_ID = LocationLocalConstants.UNKNOWN_LOCATION_ID
47
47
  DEFAULT_PROFILE_ID = 0
48
48
 
49
- GOOGLE_CSV_DATA_SOURCE_TYPE_ID = 16
50
- OUTLOOK_CSV_DATA_SOURCE_TYPE_ID = 17
51
- LINKEDIN_CSV_DATA_SOURCE_TYPE_ID = 18
52
- BGU_COURSE_CSV_DATA_SOURCE_TYPE_ID = 57
53
- RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID = 60
54
-
55
49
 
56
50
  # Those methods should be called from the common method for this repo (contact-person-profile-csv-imp-local-python-package and google-contact-sync ...)
57
51
 
@@ -136,6 +130,16 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
136
130
  self.importers_local = ImportersLocal()
137
131
  self.data_sources = DataSources()
138
132
  self.groups_list = None
133
+ self.unknown_main_group_type_id = self.select_one_value_by_column_and_value(
134
+ schema_name='group', view_table_name='group_type_ml_view',
135
+ select_clause_value='group_type_id', column_name='title', column_value='Unknown')
136
+ self.organization_main_group_type_id = self.select_one_value_by_column_and_value(
137
+ schema_name='group', view_table_name='group_type_ml_view',
138
+ select_clause_value='group_type_id', column_name='title', column_value='Organization')
139
+ self.job_title_main_group_type_id = self.select_one_value_by_column_and_value(
140
+ schema_name='group', view_table_name='group_type_ml_view',
141
+ select_clause_value='group_type_id', column_name='title', column_value='Job Title')
142
+
139
143
 
140
144
  # # TODO Does this function should be here on in https://github.com/circles-zone/variable-local-python-package/tree/dev/variable_local_python_package/variable_local/src "field/field.py"?
141
145
  # def __get_field_name(self, field_id: int, data_source_type_id: int) -> str:
@@ -172,23 +176,29 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
172
176
  self, *, data_source_type_id: int, file_name: str = None, user_external_username: str, system_id: int = None,
173
177
  # TODO Add support to criteria_set_id
174
178
  directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
175
- groups_dicts: dict = None, profile_id: int = None) -> dict:
179
+ groups_dicts: list[dict] = None, profile_id: int = None) -> dict:
176
180
  """
177
181
  Insert contacts from CSV file to the database
178
- :param data_source_type_id: The data source ID
182
+ :param data_source_type_id: The data source id
179
183
  :param file_name: The CSV file name
180
184
  :param user_external_username: The user external username
185
+ :param system_id: The system id
186
+ :param user_external_username: The user external username
187
+ :param groups_dicts: The groups list
188
+ :param profile_id: The profile ID
181
189
  :param directory_name: The CSV file directory name if it wasn't given it will search for the file in the same directory
182
190
  :param csv_path: The CSV file path if it wasn't given it will search for the file in the same directory
183
191
  :param start_index: The start index
184
192
  :param end_index: The end index
185
193
  :return:
186
194
  """
187
-
195
+ data_source_type_name = DataSources().get_data_source_name_by_id(data_source_type_id)
188
196
  profile_id_by_email_address = ProfilesLocal().select_one_value_by_column_and_value(
189
197
  schema_name="profile", view_table_name="profile_view",
190
198
  select_clause_value="profile_id", column_name="profile.main_email_address",
191
199
  column_value=user_external_username)
200
+ system_id = system_id or CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID
201
+ self.set_schema(schema_name="field")
192
202
  profile_id = profile_id or profile_id_by_email_address
193
203
  self.groups_list = groups_dicts if groups_dicts else []
194
204
  '''
@@ -219,7 +229,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
219
229
  'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
220
230
  'address2_country', 'job_title', 'organization', 'display_as')
221
231
 
222
- user_external_id = self.__get_user_external_id(user_external_username=user_external_username, profile_id=profile_id)
232
+ user_external_id = self.__get_user_external_id(user_external_username=user_external_username,
233
+ profile_id=profile_id, system_id=system_id)
223
234
  # We create a new data_source_instance_id everytime we import a new csv file
224
235
  data_source_instance_id = self.__get_data_source_instance_id(
225
236
  data_source_type_id=data_source_type_id, csv_file_path=csv_file_path,
@@ -310,12 +321,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
310
321
  # TODO We should take care of situation which the contact already exists and we need to update it
311
322
  contact_dict["data_source_instance_id"] = data_source_instance_id
312
323
  contact_dict["data_source_type_id"] = data_source_type_id
313
- source_str = self.get_data_source_type_name_by_data_source_type_id(data_source_type_id) or "CSV Import"
314
- contact_dict["source"] = source_str
324
+ contact_dict["source"] = data_source_type_name
315
325
  contact_dict["owner_profile_id"] = profile_id
316
326
  contact_dict["system_id"] = system_id
317
327
  contact_dict = CSVToContactPersonProfile.fix_contact_dict_by_data_source_type(
318
- contact_dict=contact_dict, data_source_type_id=data_source_type_id)
328
+ contact_dict=contact_dict)
319
329
  contact_id = self.contacts_local.upsert_contact_dict(contact_dict=contact_dict)
320
330
  contact_dict["contact_id"] = contact_id
321
331
  if contact_id:
@@ -437,8 +447,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
437
447
  contact_id=contact_dict.get("contact_id"), location_id=contact_dict.get("location_id") or DEFAULT_LOCATION_ID,
438
448
  user_external_id=user_external_id,
439
449
  data_source_instance_id=data_source_instance_id,
440
- data_source_type_id=data_source_type_id
441
- )
450
+ data_source_type_id=data_source_type_id)
442
451
  return importer_id
443
452
 
444
453
  # TODO Move this method to LocationsLocal
@@ -505,11 +514,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
505
514
  organization = contact_dict.get("organization")
506
515
  if organization:
507
516
  organization_group_dict = {
517
+ # table:
508
518
  "name": organization,
509
519
  "hashtag": '#' + organization.upper(),
510
520
  "is_organization": 1,
511
- "main_group_type_id": 2000, # TODO: Shall we get it from db or from constant?
512
- # ml table
521
+ "main_group_type_id": self.organization_main_group_type_id,
522
+ # ml table:
513
523
  "is_main_title": False,
514
524
  "title": organization,
515
525
  }
@@ -517,11 +527,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
517
527
  job_title = contact_dict.get("job_title")
518
528
  if job_title:
519
529
  job_title_group_dict = {
530
+ # table:
520
531
  "name": job_title,
521
532
  "hashtag": '#' + job_title.upper(),
522
533
  "is_job_title": 1,
523
- "main_group_type_id": 3001, # TODO: Shall we get it from db or from constant?
524
- # ml table
534
+ "main_group_type_id": self.job_title_main_group_type_id,
535
+ # ml table:
525
536
  "is_main_title": False,
526
537
  "title": job_title,
527
538
  }
@@ -530,10 +541,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
530
541
  _groups = contact_dict.get("groups").split(", ")
531
542
  for group in _groups:
532
543
  group_dict = {
544
+ # table:
533
545
  "name": group,
534
546
  "hashtag": '#' + group.upper(),
535
- "main_group_type_id": 0, # TODO: Shall we get it from db or from constant?
536
- # ml table
547
+ "main_group_type_id": self.unknown_main_group_type_id,
548
+ # ml table:
537
549
  "is_main_title": False,
538
550
  "title:": group,
539
551
  }
@@ -566,7 +578,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
566
578
 
567
579
  return contact_person_results_dict
568
580
 
569
- # TODO This method is confusing me as based on the name I was expected to to have two parameters contact_dict and email_addresses but we are sending profile_id, please explain or fix
581
+ # TODO This method is confusing me as based on the name I was expected to to have two parameters
582
+ # contact_dict and email_addresses but we are sending profile_id, please explain or fix
570
583
  def __insert_link_contact_email_addresses(self, contact_dict: dict) -> list[int]:
571
584
  email_addresses = self.contacts_local.get_contact_email_addresses_from_contact_dict(
572
585
  contact_dict=contact_dict)
@@ -610,6 +623,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
610
623
  contact_dict=contact_dict,
611
624
  contact_email_address=contact_dict["email1"],
612
625
  contact_id=contact_id,
626
+ system_id=contact_dict.get("system_id"),
613
627
  user_external_dict={"username": contact_dict["email1"]}
614
628
  )
615
629
 
@@ -658,16 +672,16 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
658
672
  def __insert_importer(self, contact_id: int, location_id: int, user_external_id: int,
659
673
  data_source_type_id: int, data_source_instance_id: int) -> int:
660
674
  # TODO: Shall we consider the url of csv's as the following? Use Sql2Code. Use const enum
661
- if data_source_type_id == GOOGLE_CSV_DATA_SOURCE_TYPE_ID:
675
+ if data_source_type_id == CSVToContactPersonProfileConstants.GOOGLE_CSV_DATA_SOURCE_TYPE_ID:
662
676
  url = "www.google.com"
663
- elif data_source_type_id == OUTLOOK_CSV_DATA_SOURCE_TYPE_ID:
677
+ elif data_source_type_id == CSVToContactPersonProfileConstants.OUTLOOK_CSV_DATA_SOURCE_TYPE_ID:
664
678
  url = "www.outlook.com"
665
- elif data_source_type_id == LINKEDIN_CSV_DATA_SOURCE_TYPE_ID:
679
+ elif data_source_type_id == CSVToContactPersonProfileConstants.LINKEDIN_CSV_DATA_SOURCE_TYPE_ID:
666
680
  url = "www.linkedin.com"
667
681
  # TODO Please change all Magic Numbers to data generated by Sql2Code
668
- elif data_source_type_id == BGU_COURSE_CSV_DATA_SOURCE_TYPE_ID:
682
+ elif data_source_type_id == CSVToContactPersonProfileConstants.BGU_COURSE_CSV_DATA_SOURCE_TYPE_ID:
669
683
  url = None
670
- elif data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
684
+ elif data_source_type_id == CSVToContactPersonProfileConstants.RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
671
685
  url = None
672
686
  else:
673
687
  raise ValueError("data_source_type_id is not valid")
@@ -818,7 +832,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
818
832
  # TODO use enum const for "email1" ....
819
833
  return emails_list
820
834
 
821
- def __get_user_external_id(self, user_external_username: str, profile_id: int) -> int or None:
835
+ def __get_user_external_id(self, user_external_username: str, profile_id: int, system_id: int) -> int or None:
822
836
 
823
837
  user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
824
838
  select_clause_value="user_external_id", column_name="username",
@@ -827,7 +841,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
827
841
  self.user_externals_local.insert_or_update_user_external_access_token(
828
842
  username=user_external_username,
829
843
  profile_id=profile_id,
830
- system_id=CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID,
844
+ system_id=system_id,
831
845
  access_token=""
832
846
  )
833
847
  user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
@@ -871,23 +885,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
871
885
  return result['encoding']
872
886
 
873
887
  @staticmethod
874
- def fix_contact_dict_by_data_source_type(contact_dict: dict, data_source_type_id: int) -> dict:
875
- if data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
888
+ def fix_contact_dict_by_data_source_type(contact_dict: dict) -> dict:
889
+ if contact_dict.get('data_source_type_id') == CSVToContactPersonProfileConstants.RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
876
890
  if contact_dict.get('phone1'):
877
891
  cellphone_number = contact_dict.get('phone1')
878
892
  if cellphone_number.startswith('0'):
879
893
  cellphone_number = '+972 ' + cellphone_number
880
894
  contact_dict['phone1'] = cellphone_number
881
895
  return contact_dict
882
-
883
- def get_data_source_type_name_by_data_source_type_id(self, data_source_type_id: int) -> str:
884
- if data_source_type_id == GOOGLE_CSV_DATA_SOURCE_TYPE_ID:
885
- return "Google Contact CSV File"
886
- elif data_source_type_id == OUTLOOK_CSV_DATA_SOURCE_TYPE_ID:
887
- return "Outlook Contact CSV File"
888
- elif data_source_type_id == LINKEDIN_CSV_DATA_SOURCE_TYPE_ID:
889
- return "Linkedin Contact CSV File"
890
- elif data_source_type_id == BGU_COURSE_CSV_DATA_SOURCE_TYPE_ID:
891
- return "BGU Course CSV File"
892
- elif data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
893
- return "Rishon Muni Exhibitor CSV File"
@@ -19,3 +19,9 @@ class CSVToContactPersonProfileConstants:
19
19
  'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
20
20
  'developer_email': DEVELOPER_EMAIL
21
21
  }
22
+
23
+ GOOGLE_CSV_DATA_SOURCE_TYPE_ID = 16
24
+ LINKEDIN_CSV_DATA_SOURCE_TYPE_ID = 18
25
+ OUTLOOK_CSV_DATA_SOURCE_TYPE_ID = 17
26
+ BGU_COURSE_CSV_DATA_SOURCE_TYPE_ID = 57
27
+ RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID = 60
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
5
5
  Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
6
6
  Author: Circles
@@ -5,7 +5,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
5
5
 
6
6
  setuptools.setup(
7
7
  name=PACKAGE_NAME,
8
- version='0.0.34', # https://pypi.org/project/contact-person-profile-csv-imp-local/
8
+ version='0.0.36', # https://pypi.org/project/contact-person-profile-csv-imp-local/
9
9
  author="Circles",
10
10
  author_email="info@circles.ai",
11
11
  description="PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python",