leadguru-jobs 0.173.0__py3-none-any.whl → 0.175.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.173.0
3
+ Version: 0.175.0
4
4
  Summary: LGT jobs builds
5
5
  Author-email: developer@leadguru.co
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -20,6 +20,6 @@ Classifier: Topic :: Internet
20
20
  Requires-Dist: loguru
21
21
  Requires-Dist: pydantic
22
22
  Requires-Dist: cachetools (>=3.1.0)
23
- Requires-Dist: leadguru-common (>=0.272.0)
24
- Requires-Dist: leadguru-data (>=0.279.0)
23
+ Requires-Dist: leadguru-common (>=0.273.0)
24
+ Requires-Dist: leadguru-data (>=0.280.0)
25
25
 
@@ -1,15 +1,15 @@
1
1
  lgt_jobs/__init__.py,sha256=pKgJxoeO0rQFY5svK240kM0vGQdh0K4eUeE2uhp8jq8,3236
2
2
  lgt_jobs/basejobs.py,sha256=Bg4wXVGpVlWI-aBiHy1xnHuP-hDmrn7EQYC0Vn42lf8,1281
3
3
  lgt_jobs/env.py,sha256=6e2HLmbp54WR-a5xkzs1ctdvyxVEtwgq25EnA1Zs_sQ,953
4
- lgt_jobs/main.py,sha256=bhabv2JMt9BgIBhjcjkx_PrNv-bfeizcXvT0zdfTi9I,1534
4
+ lgt_jobs/main.py,sha256=HvFVkh-ABOzb6X7liasry3rjO7-601aw9UX4y1EPgek,1589
5
5
  lgt_jobs/runner.py,sha256=z-IjPSUCrm-Lhp-xjJC7gNIuvFWccb76mkMlc5mv3QQ,2248
6
6
  lgt_jobs/simple_job.py,sha256=rxKichpwaBKjwITnMy9irX5-53cbSK4TFKah9Tc2zYc,534
7
7
  lgt_jobs/smtp.py,sha256=MZCz3OOOSrDEbdC2rg7LtC3K-EnveB6T2zHA5PEv34Q,1390
8
8
  lgt_jobs/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- lgt_jobs/jobs/analytics.py,sha256=MXqdXvpfOr4MwrLDtHpFiaacYTmlSPzUs7XoW25ke50,1301
9
+ lgt_jobs/jobs/analytics.py,sha256=vO6nuDtZALujNp3O0GT4aYLQ2jXHCn6RPXm4VTisC2M,1309
10
10
  lgt_jobs/jobs/archive_leads.py,sha256=Q5AzjQKUNOCcg9tmjhSwyJtXaSKkEhbFh90inS65iYw,858
11
11
  lgt_jobs/jobs/bot_stats_update.py,sha256=sHOVFdwACKt8EerUk6tue220Ejtt1IZTmKekC3-TFmI,2975
12
- lgt_jobs/jobs/chat_history.py,sha256=hs0Q34gGn16xTgt3FnbwHVXnLoUl4zd0Nuhw3uqqlU4,5757
12
+ lgt_jobs/jobs/chat_history.py,sha256=WlzyNjsGtE28oI--Zf1zm57uTl0sXYTIDh5f1cvmgww,5812
13
13
  lgt_jobs/jobs/clear_user_analytics.py,sha256=VJWkgGGk6QmlZnvCSiZ7jo04VI6gfyPzNw2nsUSHhSo,2532
14
14
  lgt_jobs/jobs/connected_workspaces.py,sha256=7QgRdc9Yjx7JLWmjdohodDDRJ5deTu981LzWJVZeGZg,7439
15
15
  lgt_jobs/jobs/conversation_replied.py,sha256=JyWEiKQ2G0gsTu3dXFy1VsKi2nGI9H4044poI07ArR4,2932
@@ -18,9 +18,9 @@ lgt_jobs/jobs/reindex_conversation_history.py,sha256=Jvve9swOYUmCv7qqG8B_iKLxljN
18
18
  lgt_jobs/jobs/send_slack_message.py,sha256=BWos34bHn9QA8LM9hmKixEnY51auzXLH2jEkRjW3iBw,1812
19
19
  lgt_jobs/jobs/update_slack_profile.py,sha256=uj-3vGy_iwph8tNFnozmdTULGM9z04qW_d-7Prkv7vg,3918
20
20
  lgt_jobs/jobs/user_balance_update.py,sha256=5rLS3xUCoDZ03ypw8Vq4-zcjS2VubQc0eBXxpfSG8nQ,2366
21
- lgt_jobs/jobs/user_limits_update.py,sha256=aXJOVLeLFKFMikly92JuCPWqEhWTGaJlCIo5o7jsZXo,2662
21
+ lgt_jobs/jobs/user_limits_update.py,sha256=ux9p9Dtpc3DQ73QokV71N6ilX47z6IPzpjXgKgCTJUA,2797
22
22
  lgt_jobs/templates/new_message_mail_template.html,sha256=gn913h6LSm5kEiqRNrKCtUtVj9WXVU5BrbYGe8vA8fY,3704
23
- leadguru_jobs-0.173.0.dist-info/METADATA,sha256=7ZSTX19zmiE4wtRs2yRD-UsLbZ73n3fNkaMKQe6ym6g,1008
24
- leadguru_jobs-0.173.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
25
- leadguru_jobs-0.173.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
26
- leadguru_jobs-0.173.0.dist-info/RECORD,,
23
+ leadguru_jobs-0.175.0.dist-info/METADATA,sha256=TyG6RlJzCX5IFpmFJyed3ui2wbqK37byMGNfYFXE63M,1008
24
+ leadguru_jobs-0.175.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
25
+ leadguru_jobs-0.175.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
26
+ leadguru_jobs-0.175.0.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  from abc import ABC
2
2
  import datetime
3
- from typing import Optional
3
+ from typing import Optional, List
4
4
 
5
5
  from pydantic import BaseModel, conlist
6
6
  from pymongo import MongoClient
@@ -17,7 +17,7 @@ class TrackAnalyticsJobData(BaseBackgroundJobData, BaseModel):
17
17
  data: str
18
18
  name: str
19
19
  event: str
20
- extra_id: Optional[str]
20
+ extra_ids: List[str] = []
21
21
  attributes: conlist(Optional[str], min_items=1)
22
22
  created_at: datetime.datetime
23
23
 
@@ -31,7 +31,8 @@ class LoadChatHistoryJob(BaseBackgroundJob, ABC):
31
31
  for message in current_chat:
32
32
  same_message = [msg for msg in saved_chat if msg.ts == message.ts]
33
33
  if same_message:
34
- message.text = same_message[0].text
34
+ same_message[0].text = message.text
35
+ same_message[0].files = message.files
35
36
  else:
36
37
  saved_chat.append(message)
37
38
 
@@ -1,27 +1,27 @@
1
1
  from abc import ABC
2
2
  from datetime import datetime
3
3
  from typing import List
4
- from cachetools import cached, TTLCache
5
4
  from lgt_data.engine import UserCreditStatementDocument
6
5
  from lgt_data.enums import UserAccountState
7
6
  from lgt_data.model import UserModel
8
7
  from lgt_data.mongo_repository import UserMongoRepository, DedicatedBotRepository, to_object_id
9
8
  from pydantic import BaseModel
10
9
  from .analytics import TrackAnalyticsJobData, TrackAnalyticsJob
10
+ from ..basejobs import BaseBackgroundJobData, BaseBackgroundJob
11
11
 
12
12
  """
13
13
  User limits handling
14
14
  """
15
15
 
16
16
 
17
- class UpdateUserDataUsageJobData(BaseModel):
17
+ class UpdateUserDataUsageJobData(BaseBackgroundJobData, BaseModel):
18
18
  channel_id: str
19
19
  bot_name: str
20
20
  filtered: bool
21
21
  user_ids: List[str]
22
22
 
23
23
 
24
- class UpdateUserDataUsageJob(ABC):
24
+ class UpdateUserDataUsageJob(BaseBackgroundJob, ABC):
25
25
  @property
26
26
  def job_data_type(self) -> type:
27
27
  return UpdateUserDataUsageJobData
@@ -69,4 +69,6 @@ class UpdateUserDataUsageJob(ABC):
69
69
 
70
70
  dedicated_bot = DedicatedBotRepository().get_by_user_and_name(user.id, data.bot_name)
71
71
  if dedicated_bot and not dedicated_bot.invalid_creds:
72
- self.increment(f"{user.id}", data.filtered, bot_name=data.bot_name, dedicated_bot_id=dedicated_bot.id)
72
+ self.increment(f"{user.id}", data.filtered,
73
+ bot_name=data.bot_name,
74
+ dedicated_bot_id=str(dedicated_bot.id))
lgt_jobs/main.py CHANGED
@@ -10,6 +10,7 @@ from lgt_jobs import env
10
10
 
11
11
  lock = threading.Lock()
12
12
 
13
+
13
14
  def run_background_job(data):
14
15
  try:
15
16
  log.info(f"[JOB]: {data} [START]")
@@ -18,6 +19,7 @@ def run_background_job(data):
18
19
  except Exception:
19
20
  raise
20
21
 
22
+
21
23
  def run_background_job_with_lock(message):
22
24
  try:
23
25
  data = json.loads(message.data)
@@ -35,10 +37,11 @@ def run_background_job_with_lock(message):
35
37
  if __name__ == '__main__':
36
38
  factory = PubSubFactory(env.project_id)
37
39
  factory.create_topic_if_doesnt_exist(env.background_jobs_topic)
38
- factory.create_subscription_if_doesnt_exist(env.background_jobs_subscriber, env.background_jobs_topic, ack_deadline_seconds=600)
40
+ factory.create_subscription_if_doesnt_exist(env.background_jobs_subscriber, env.background_jobs_topic,
41
+ ack_deadline_seconds=600)
39
42
  bot_subscription_path = factory.get_subscription_path(env.background_jobs_subscriber, env.background_jobs_topic)
40
43
 
41
44
  factory.subscriber.subscribe(bot_subscription_path, callback=run_background_job_with_lock)
42
45
  print(f'Listening for messages on {bot_subscription_path}')
43
46
  while True:
44
- time.sleep(1)
47
+ time.sleep(1)