leadguru-jobs 0.544.0__py3-none-any.whl → 0.545.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.544.0
3
+ Version: 0.545.0
4
4
  Summary: LGT jobs builds
5
5
  Author-email: developer@leadguru.co
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -2,7 +2,7 @@ lgt_jobs/__init__.py,sha256=lrhMUJ7a5YSkYswQkQe981b_w8h8NHyncwfEduXEq6Q,1992
2
2
  lgt_jobs/basejobs.py,sha256=LPEclvY6fIG17YMGy9pRK0Q58n62gkI5W1BTK6R2p-c,1234
3
3
  lgt_jobs/env.py,sha256=cRO03GGvstUjBsv3uYO-iakrOvAk_ZWUP_fnmf21iZQ,789
4
4
  lgt_jobs/main.py,sha256=cK_nkBtJHnUNDbba1WZotqPtI_6OWxiYQkAgco9OAmE,1539
5
- lgt_jobs/runner.py,sha256=MZ3_UvfyDSM707UI4uPDntlKKCXkIyN6h95D1i1SoQQ,2125
5
+ lgt_jobs/runner.py,sha256=7KHpMHWwCjDlPDKnkNqrGAyIVn4Po62VqjYGVa85if8,2218
6
6
  lgt_jobs/simple_job.py,sha256=sta7MP-57iwRewPycmTAc9dvSbocbGjWhb1QYYj7ccA,519
7
7
  lgt_jobs/smtp.py,sha256=Svaq2ghMjGwpPA4J92wVnzrLlVbI2FcM2d4liiAbHLo,1210
8
8
  lgt_jobs/assets/images/arrow.png,sha256=Lr_zG1TyySAWX78jiojcV7j8BHe2S_Oi7eZYAfe4YbM,536
@@ -37,7 +37,7 @@ lgt_jobs/lgt_common/slack_client/methods.py,sha256=ctKF_1UHEmSWaRsoGEgMZicVabV7e
37
37
  lgt_jobs/lgt_common/slack_client/slack_client.py,sha256=6Jgz0ELARcqknL9YBW4yph75E_AUsDGBsoTpcoYNMBQ,13479
38
38
  lgt_jobs/lgt_common/slack_client/web_client.py,sha256=JOW-VGYYGqFZgyoqjOZ3t_XUdZAOttETVjVBZUWiUDM,6245
39
39
  lgt_jobs/lgt_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- lgt_jobs/lgt_data/analytics.py,sha256=FJxImuuJw-m4B-eKIddytBy_B19BVsdPEHib-5gNgyo,20172
40
+ lgt_jobs/lgt_data/analytics.py,sha256=TFUffL8Dn-vIJ3ZaCVN-cj1Qnjb8F9GJyuk6Fo7mR1s,21645
41
41
  lgt_jobs/lgt_data/engine.py,sha256=Rsbz-CApAo_TVDssdjBkv8v_fVOZm_Uh1S6W4fnaEWo,7728
42
42
  lgt_jobs/lgt_data/enums.py,sha256=pZz8Xv-44hhhttb01ci4YnMIj7gS1oNnhX24XnuX5UM,2160
43
43
  lgt_jobs/lgt_data/helpers.py,sha256=NDa-V5EYaJfkGoWsmQSwSe6N_jxNxs8tHRQzW1iST6k,480
@@ -46,7 +46,7 @@ lgt_jobs/lgt_data/mongo_repository.py,sha256=6Cv5L90jUPgzTbv5vCjsGSOkeCdzVJf0pTR
46
46
  lgt_jobs/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  lgt_jobs/services/web_client.py,sha256=GLWsJkIC8rv6xLFaLwcMm4EwBlVDu0njORwkZqBJaE4,2086
48
48
  lgt_jobs/templates/new_message.html,sha256=BD_E90akmQ1Wf07wtZAjeK_7DUKRmja5HFHVo_AKI24,6994
49
- leadguru_jobs-0.544.0.dist-info/METADATA,sha256=r1tD2YPghm4E8ID9f5OBosLGwnywHC-VYLAlBLRwdqA,1319
50
- leadguru_jobs-0.544.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
51
- leadguru_jobs-0.544.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
52
- leadguru_jobs-0.544.0.dist-info/RECORD,,
49
+ leadguru_jobs-0.545.0.dist-info/METADATA,sha256=BYTjMaCmqkJ4CNTyv5RTAuUQLInOEj_pWXKn2WDeuY0,1319
50
+ leadguru_jobs-0.545.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
51
+ leadguru_jobs-0.545.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
52
+ leadguru_jobs-0.545.0.dist-info/RECORD,,
@@ -81,6 +81,51 @@ def _prepare_date_analytics_doc(doc, ordered_result_dict: Dict[str, int]):
81
81
  ordered_result_dict[str_date] = item["count"]
82
82
  return ordered_result_dict
83
83
 
84
+ def get_channel_aggregated_analytics(from_date: datetime = None, to_date: datetime = None,
85
+ bot_id: Optional[str | ObjectId] = None):
86
+ pipeline = [
87
+ {
88
+ '$match': {
89
+ 'extra_ids': {"$in": [str(bot_id)]}
90
+ }
91
+ },
92
+ {
93
+ "$group": {
94
+ '_id': {
95
+ '$arrayElemAt': [
96
+ '$attributes', 0
97
+ ]
98
+ },
99
+ 'count': {"$sum": 1}
100
+ }
101
+ },
102
+ {
103
+ '$limit': 1000
104
+ }
105
+ ]
106
+
107
+ if from_date:
108
+ beginning_of_the_day = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0, 0)
109
+ pipeline.insert(0, {"$match": {"created_at": {"$gte": beginning_of_the_day}}})
110
+
111
+ if to_date:
112
+ end_of_the_day = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59, 999)
113
+ pipeline.insert(0, {"$match": {"created_at": {"$lte": end_of_the_day}}})
114
+
115
+ received_messages = list(db[f'received_messages'].aggregate(pipeline))
116
+ filtered_messages = list(db[f'filtered_messages'].aggregate(pipeline))
117
+
118
+ received_messages_dic = OrderedDict()
119
+ filtered_messages_dic = OrderedDict()
120
+
121
+ for item in received_messages:
122
+ received_messages_dic[item["_id"]] = item["count"]
123
+
124
+ for item in filtered_messages:
125
+ filtered_messages_dic[item["_id"]] = item["count"]
126
+
127
+ return received_messages_dic, filtered_messages_dic
128
+
84
129
 
85
130
  def get_aggregated_user_leads(user_id: Union[ObjectId, str],
86
131
  from_date: datetime,
lgt_jobs/runner.py CHANGED
@@ -32,13 +32,15 @@ class BackgroundJobRunner:
32
32
  BackgroundJobRunner.submit_data(job_data)
33
33
 
34
34
  @staticmethod
35
- def submit_data(data: dict):
35
+ def submit_data(data: dict, topic: str = None):
36
36
  json_str = json.dumps(data, ensure_ascii=False, default=datetime_converter)
37
- BackgroundJobRunner.submit_json(json_str)
37
+ BackgroundJobRunner.submit_json(json_str, topic)
38
38
 
39
39
  @staticmethod
40
- def submit_json(json_str: str):
41
- publish_message2_pubsub(background_jobs_topic, message_json=json_str)
40
+ def submit_json(json_str: str, topic: str = None):
41
+ if not topic:
42
+ topic = background_jobs_topic
43
+ publish_message2_pubsub(topic, message_json=json_str)
42
44
 
43
45
  @staticmethod
44
46
  def schedule(jib: str, job: type, data: BaseBackgroundJobData, scheduled_at: datetime):