leadguru-jobs 0.544.0__py3-none-any.whl → 0.546.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.
- {leadguru_jobs-0.544.0.dist-info → leadguru_jobs-0.546.0.dist-info}/METADATA +1 -1
- {leadguru_jobs-0.544.0.dist-info → leadguru_jobs-0.546.0.dist-info}/RECORD +8 -8
- lgt_jobs/lgt_data/analytics.py +45 -0
- lgt_jobs/lgt_data/enums.py +2 -2
- lgt_jobs/lgt_data/mongo_repository.py +4 -10
- lgt_jobs/runner.py +6 -4
- {leadguru_jobs-0.544.0.dist-info → leadguru_jobs-0.546.0.dist-info}/WHEEL +0 -0
- {leadguru_jobs-0.544.0.dist-info → leadguru_jobs-0.546.0.dist-info}/top_level.txt +0 -0
@@ -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=
|
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,16 +37,16 @@ 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=
|
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
|
-
lgt_jobs/lgt_data/enums.py,sha256=
|
42
|
+
lgt_jobs/lgt_data/enums.py,sha256=GZn6wm-kOd3veEOo1qlOR8QYje4vKaGV0na9jGt9388,2160
|
43
43
|
lgt_jobs/lgt_data/helpers.py,sha256=NDa-V5EYaJfkGoWsmQSwSe6N_jxNxs8tHRQzW1iST6k,480
|
44
44
|
lgt_jobs/lgt_data/model.py,sha256=DDfoWeH6rLWKoZsFJ2tI5Yagj1WlOa0PIJp-GqBIVSA,28112
|
45
|
-
lgt_jobs/lgt_data/mongo_repository.py,sha256=
|
45
|
+
lgt_jobs/lgt_data/mongo_repository.py,sha256=qqbt-oJ-RHmICLARgWvHuyPwVeKFkUqJZ2MA1bfIlXs,44762
|
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.
|
50
|
-
leadguru_jobs-0.
|
51
|
-
leadguru_jobs-0.
|
52
|
-
leadguru_jobs-0.
|
49
|
+
leadguru_jobs-0.546.0.dist-info/METADATA,sha256=IWNYd7KvvxOxUUCq4AtUk6Kqg4id5_GJ-y8Oz5mLQEQ,1319
|
50
|
+
leadguru_jobs-0.546.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
51
|
+
leadguru_jobs-0.546.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
|
52
|
+
leadguru_jobs-0.546.0.dist-info/RECORD,,
|
lgt_jobs/lgt_data/analytics.py
CHANGED
@@ -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/lgt_data/enums.py
CHANGED
@@ -61,12 +61,12 @@ class BotEventType(str, Enum):
|
|
61
61
|
|
62
62
|
class ImageName(str, Enum):
|
63
63
|
ARROW = 'arrow.png'
|
64
|
+
CRY = 'cry.png'
|
64
65
|
FIREWORK = 'firework.png'
|
66
|
+
HANDS = 'hands.png'
|
65
67
|
LOCK = 'lock.png'
|
66
68
|
LOGO = 'logo.png'
|
67
69
|
MAIL = 'mail.png'
|
68
|
-
CRY = 'cry.png'
|
69
|
-
HANDS = 'hands.png'
|
70
70
|
SAD = 'sad.png'
|
71
71
|
|
72
72
|
|
@@ -831,16 +831,10 @@ class DedicatedBotRepository(BaseMongoRepository):
|
|
831
831
|
docs = self.collection().find(pipeline)
|
832
832
|
return [DedicatedBotModel.from_dic(doc) for doc in docs]
|
833
833
|
|
834
|
-
def get_source_ids_for_user(self,
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
}, {
|
839
|
-
'_id': 0,
|
840
|
-
'source_id': '$source.source_id'
|
841
|
-
})
|
842
|
-
source_ids = [item['source_id'] for item in docs]
|
843
|
-
return source_ids
|
834
|
+
def get_source_ids_for_user(self, **kwargs):
|
835
|
+
pipeline = self.__create_bots_filter(**kwargs)
|
836
|
+
docs = self.collection().find(pipeline, projection={'_id': 0, 'source_id': '$source.source_id'})
|
837
|
+
return [item['source_id'] for item in docs]
|
844
838
|
|
845
839
|
def get_one(self, **kwargs):
|
846
840
|
pipeline = self.__create_bots_filter(**kwargs)
|
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
|
-
|
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):
|
File without changes
|
File without changes
|