leadguru-jobs 0.518.0__py3-none-any.whl → 0.519.0__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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: leadguru_jobs
3
- Version: 0.518.0
3
+ Version: 0.519.0
4
4
  Summary: LGT jobs builds
5
5
  Author-email: developer@leadguru.co
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -14,7 +14,7 @@ lgt_jobs/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  lgt_jobs/jobs/analytics.py,sha256=IIsWt4A1qUw3w-S-8W16uKY1FRVWfXXA41_mu4uCNiM,979
15
15
  lgt_jobs/jobs/bot_stats_update.py,sha256=zCSiX3olnipZaqUyC81TvvHvIcM1xEvsepj0ai03VoE,7397
16
16
  lgt_jobs/jobs/chat_history.py,sha256=kP9s_Zprwg1dAtSma5U_YcfhdkD4IAmZso30n-W4JlY,6302
17
- lgt_jobs/jobs/inbox_leads.py,sha256=0t2JRhDL_8Ku-YxQGmwTqlHeuXOQdquV74Dsoz3_TmY,4634
17
+ lgt_jobs/jobs/inbox_leads.py,sha256=MvMXwBzRIO5yoYEKPipqDfl5Il1rh0I_5HQz2mpZXZo,5357
18
18
  lgt_jobs/jobs/mass_message.py,sha256=1mFcBlL2MhzLbj5yrd_NyJc7TXDWCcROAzGDnr0miMU,2035
19
19
  lgt_jobs/jobs/send_code.py,sha256=dIlLPkG3GgGKIEqGiElyzrtdrnJNTL1Ak2V0xnE-WIQ,824
20
20
  lgt_jobs/jobs/send_slack_message.py,sha256=WdXXh7QpjJKSvDU93YT9QKzoGRNBpPCJgiIxPs5gp1s,2782
@@ -47,7 +47,7 @@ lgt_jobs/lgt_data/mongo_repository.py,sha256=h3xA2AvqHaiQfl4vg88SdOKBczJ0P6bpkZY
47
47
  lgt_jobs/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  lgt_jobs/services/web_client.py,sha256=GLWsJkIC8rv6xLFaLwcMm4EwBlVDu0njORwkZqBJaE4,2086
49
49
  lgt_jobs/templates/new_message.html,sha256=BD_E90akmQ1Wf07wtZAjeK_7DUKRmja5HFHVo_AKI24,6994
50
- leadguru_jobs-0.518.0.dist-info/METADATA,sha256=v-ERBHpeSc1j6v4NM0fwd3eXIEV5VBQ2S8xLUskPVb0,1319
51
- leadguru_jobs-0.518.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
- leadguru_jobs-0.518.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
53
- leadguru_jobs-0.518.0.dist-info/RECORD,,
50
+ leadguru_jobs-0.519.0.dist-info/METADATA,sha256=_u63NxGr3j8h-Y1qpvs55kx6J_XoaQqIXc6aqgP_jHY,1319
51
+ leadguru_jobs-0.519.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
+ leadguru_jobs-0.519.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
53
+ leadguru_jobs-0.519.0.dist-info/RECORD,,
@@ -8,6 +8,7 @@ from lgt_jobs.lgt_data.mongo_repository import UserMongoRepository, DedicatedBot
8
8
  from pydantic import BaseModel
9
9
  from lgt_jobs.basejobs import BaseBackgroundJob, BaseBackgroundJobData
10
10
  from lgt_jobs.services.web_client import V3ServerClient
11
+ from requests import exceptions
11
12
 
12
13
  """
13
14
  Save inbox leads
@@ -40,7 +41,16 @@ class InboxLeadsJob(BaseBackgroundJob, ABC):
40
41
  return
41
42
  slack_client = SlackWebClient(dedicated_bot.token, dedicated_bot.cookies)
42
43
 
43
- conversations_list = slack_client.get_im_list().get('channels', [])
44
+ attempt = 0
45
+ conversations_list = []
46
+ while attempt < 3:
47
+ try:
48
+ conversations_list = slack_client.get_im_list().get('channels', [])
49
+ except exceptions.JSONDecodeError as er:
50
+ log.info(f'[InboxLeadsJob]: Loading chat failed for the: {dedicated_bot.id}. '
51
+ f'Attempt: {attempt}. {str(er)}')
52
+ attempt += 1
53
+
44
54
  log.info(f'[InboxLeadsJob]: Loading chat for the: {dedicated_bot.id}. '
45
55
  f'Count of chats: {len(conversations_list)}')
46
56
  for conversation in conversations_list:
@@ -48,8 +58,17 @@ class InboxLeadsJob(BaseBackgroundJob, ABC):
48
58
  im_id = conversation.get('id')
49
59
  if sender_id == "USLACKBOT":
50
60
  continue
51
- history = slack_client.chat_history(im_id)
52
- if not history['ok']:
61
+
62
+ history = {}
63
+ while attempt < 3:
64
+ try:
65
+ history = slack_client.chat_history(im_id)
66
+ except exceptions.JSONDecodeError as er:
67
+ log.info(f'[InboxLeadsJob]: Loading chat failed for the: {dedicated_bot.id}. '
68
+ f'Attempt: {attempt}. {str(er)}')
69
+ attempt += 1
70
+
71
+ if not history.get('ok', False):
53
72
  log.warning(f'Failed to load chat for the: {dedicated_bot.id}. ERROR: {history.get("error", "")}')
54
73
  continue
55
74