leadguru-jobs 0.403.0__py3-none-any.whl → 0.405.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.
Files changed (43) hide show
  1. {leadguru_jobs-0.403.0.dist-info → leadguru_jobs-0.405.0.dist-info}/METADATA +5 -10
  2. leadguru_jobs-0.405.0.dist-info/RECORD +26 -0
  3. lgt_jobs/__init__.py +4 -4
  4. lgt_jobs/jobs/analytics.py +1 -1
  5. lgt_jobs/jobs/archive_leads.py +2 -2
  6. lgt_jobs/jobs/bot_stats_update.py +11 -10
  7. lgt_jobs/jobs/chat_history.py +6 -6
  8. lgt_jobs/jobs/inbox_leads.py +6 -5
  9. lgt_jobs/jobs/mass_message.py +2 -2
  10. lgt_jobs/jobs/send_code.py +1 -1
  11. lgt_jobs/jobs/send_slack_message.py +5 -5
  12. lgt_jobs/jobs/update_slack_profile.py +14 -12
  13. lgt_jobs/jobs/user_balance_update.py +5 -5
  14. lgt_jobs/jobs/workspace_connect.py +5 -7
  15. lgt_jobs/main.py +11 -9
  16. lgt_jobs/runner.py +9 -6
  17. lgt_jobs/smtp.py +1 -1
  18. leadguru_jobs-0.403.0.dist-info/RECORD +0 -49
  19. lgt_jobs/lgt_common/__init__.py +0 -0
  20. lgt_jobs/lgt_common/discord_client/__init__.py +0 -0
  21. lgt_jobs/lgt_common/discord_client/discord_client.py +0 -58
  22. lgt_jobs/lgt_common/discord_client/methods.py +0 -15
  23. lgt_jobs/lgt_common/enums/__init__.py +0 -0
  24. lgt_jobs/lgt_common/enums/slack_errors.py +0 -6
  25. lgt_jobs/lgt_common/helpers.py +0 -18
  26. lgt_jobs/lgt_common/lgt_logging.py +0 -15
  27. lgt_jobs/lgt_common/pubsub/__init__.py +0 -0
  28. lgt_jobs/lgt_common/pubsub/command.py +0 -14
  29. lgt_jobs/lgt_common/pubsub/messages.py +0 -37
  30. lgt_jobs/lgt_common/pubsub/pubsubfactory.py +0 -51
  31. lgt_jobs/lgt_common/slack_client/__init__.py +0 -0
  32. lgt_jobs/lgt_common/slack_client/methods.py +0 -46
  33. lgt_jobs/lgt_common/slack_client/slack_client.py +0 -392
  34. lgt_jobs/lgt_common/slack_client/web_client.py +0 -164
  35. lgt_jobs/lgt_data/__init__.py +0 -0
  36. lgt_jobs/lgt_data/analytics.py +0 -723
  37. lgt_jobs/lgt_data/engine.py +0 -223
  38. lgt_jobs/lgt_data/enums.py +0 -68
  39. lgt_jobs/lgt_data/helpers.py +0 -2
  40. lgt_jobs/lgt_data/model.py +0 -960
  41. lgt_jobs/lgt_data/mongo_repository.py +0 -980
  42. {leadguru_jobs-0.403.0.dist-info → leadguru_jobs-0.405.0.dist-info}/WHEEL +0 -0
  43. {leadguru_jobs-0.403.0.dist-info → leadguru_jobs-0.405.0.dist-info}/top_level.txt +0 -0
@@ -1,223 +0,0 @@
1
- from __future__ import annotations
2
- import os
3
- from collections import OrderedDict
4
- from datetime import datetime, UTC
5
- from mongoengine import connect, Document, DateTimeField, StringField, IntField, ObjectIdField, ListField
6
- from typing import Dict, Tuple, Optional
7
- from .mongo_repository import to_object_id, UserMongoRepository
8
-
9
- connect(host=os.environ.get('MONGO_CONNECTION_STRING', 'mongodb://127.0.0.1:27017/'), db="lgt_admin", alias="lgt_admin")
10
-
11
-
12
- class GlobalUserConfiguration(Document):
13
- created_at = DateTimeField(required=True)
14
- updated_at = DateTimeField(required=True)
15
- created_by = ObjectIdField(required=False)
16
- updated_by = ObjectIdField(required=False)
17
- dedicated_bots_days_to_remove = IntField(required=True)
18
-
19
- meta = {"db_alias": "lgt_admin"}
20
-
21
- @staticmethod
22
- def get_config() -> GlobalUserConfiguration:
23
- items = list(GlobalUserConfiguration.objects())
24
- if not items:
25
- # create default config
26
- GlobalUserConfiguration(
27
- created_at=datetime.now(UTC),
28
- updated_at=datetime.now(UTC),
29
- dedicated_bots_days_to_remove=10
30
- ).save()
31
- items = list(GlobalUserConfiguration.objects())
32
- return items[-1]
33
-
34
-
35
- class UserTrackAction(Document):
36
- user_id = ObjectIdField(required=True)
37
- action = StringField(required=True)
38
- metadata = StringField(required=False)
39
- created_at = DateTimeField(required=True)
40
- meta = {"indexes": ["user_id"], "db_alias": "lgt_admin"}
41
-
42
- @staticmethod
43
- def get_aggregated() -> Dict[str, Tuple[datetime, datetime]]:
44
- pipeline = [
45
- {
46
- "$group": {
47
- "_id": "$user_id",
48
- "last_action_at": {"$max": "$created_at"},
49
- "first_action_at": {"$min": "$created_at"}
50
- }
51
- }]
52
-
53
- result = list(UserTrackAction.objects.aggregate(*pipeline))
54
-
55
- return {str(item.get("_id")): (item["first_action_at"], item["last_action_at"]) for item in result}
56
-
57
- @staticmethod
58
- def track(user_id: str, action: str, metadata: Optional[str] = None):
59
- UserTrackAction(
60
- user_id=to_object_id(user_id),
61
- created_at=datetime.now(UTC),
62
- action=action,
63
- metadata=metadata
64
- ).save()
65
-
66
- @staticmethod
67
- def get_ws_monitoring_logs(email: str, action_subtype: str, from_date: datetime, to_date: datetime,
68
- source_id=None) -> list[UserTrackAction]:
69
-
70
- pipeline = {'action': {'$regex': f"^monitoring.*{action_subtype}$"}}
71
-
72
- if email:
73
- user = UserMongoRepository().get_by_email(email)
74
- pipeline['user_id'] = to_object_id(user.id)
75
-
76
- if from_date:
77
- start = datetime(from_date.year, from_date.month, from_date.day)
78
- pipeline['created_at__gte'] = start
79
-
80
- if to_date:
81
- end = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
82
- pipeline['created_at__lte'] = end
83
-
84
- if source_id:
85
- pipeline['metadata'] = {'$regex': f"^{source_id}:"}
86
-
87
- return list(UserTrackAction.objects(**pipeline))
88
-
89
- @staticmethod
90
- def get_global_user_actions(user_id: str = None, from_date: datetime = None,
91
- to_date: datetime = None, actions: list = None) -> \
92
- Dict[str, Dict[str, Dict[str, int]]]:
93
- pipeline = [
94
- {
95
- '$addFields': {
96
- 'created_at_formatted': {
97
- '$dateToString': {
98
- 'format': '%Y-%m-%d',
99
- 'date': '$created_at'
100
- }
101
- }
102
- }
103
- }, {
104
- '$group': {
105
- '_id': '$created_at_formatted',
106
- 'count': {
107
- '$sum': 1
108
- }
109
- }
110
- }
111
- ]
112
-
113
- if actions:
114
- pipeline.insert(0, {'$match': {'action': {'$in': actions}}})
115
-
116
- if user_id:
117
- pipeline.insert(0, {"$match": {"user_id": to_object_id(user_id)}})
118
-
119
- if from_date:
120
- beginning_of_the_day = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0, 0)
121
- pipeline.insert(0, {"$match": {"created_at": {"$gte": beginning_of_the_day}}})
122
-
123
- if to_date:
124
- end_of_the_day = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59, 999)
125
- pipeline.insert(0, {"$match": {"created_at": {"$lte": end_of_the_day}}})
126
-
127
- analytics = list(UserTrackAction.objects.aggregate(*pipeline))
128
- analytics_dic = OrderedDict()
129
- for item in analytics:
130
- analytics_dic[item["_id"]] = item["count"]
131
-
132
- return analytics_dic
133
-
134
- @staticmethod
135
- def get_daily_user_actions(user_id: str = None, from_date: datetime = None,
136
- to_date: datetime = None, actions: list = None) -> \
137
- Dict[str, Dict[str, Dict[str, int]]]:
138
- pipeline = [
139
- {
140
- '$match': {
141
- '$and': [
142
- {'action': {'$ne': 'login'}},
143
- {'action': {'$ne': 'chat.message'}}
144
- ]
145
- }
146
- },
147
- {
148
- '$group': {
149
- '_id': {
150
- 'date': {
151
- '$dateFromParts': {
152
- 'day': {
153
- '$dayOfMonth': '$created_at'
154
- },
155
- 'month': {
156
- '$month': '$created_at'
157
- },
158
- 'year': {
159
- '$year': '$created_at'
160
- }
161
- }
162
- },
163
- 'action': '$action',
164
- 'user_id': '$user_id'
165
- },
166
- 'count': {
167
- '$sum': 1
168
- }
169
- }
170
- }
171
- ]
172
-
173
- if actions:
174
- pipeline.insert(0, {'$match': {'action': {'$in': actions}}})
175
-
176
- if user_id:
177
- pipeline.insert(0, {"$match": {"user_id": to_object_id(user_id)}})
178
-
179
- if from_date:
180
- beginning_of_the_day = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0, 0)
181
- pipeline.insert(0, {"$match": {"created_at": {"$gte": beginning_of_the_day}}})
182
-
183
- if to_date:
184
- end_of_the_day = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59, 999)
185
- pipeline.insert(0, {"$match": {"created_at": {"$lte": end_of_the_day}}})
186
-
187
- analytics = list(UserTrackAction.objects.aggregate(*pipeline))
188
-
189
- result = {}
190
- for item in analytics:
191
- date = item["_id"]["date"].strftime('%Y-%m-%d')
192
- user_id = str(item["_id"]["user_id"])
193
- if date not in result:
194
- result[date] = {}
195
- if user_id not in result[date]:
196
- result[date][user_id] = {}
197
- result[date][user_id][item["_id"]["action"]] = item["count"]
198
-
199
- return result
200
-
201
-
202
- class DelayedJob(Document):
203
- created_at = DateTimeField(required=True)
204
- scheduled_at = DateTimeField(required=True)
205
- job_type = StringField(required=True)
206
- data = StringField(required=True)
207
- jib = StringField(required=True)
208
- executed_at: DateTimeField(required=False)
209
-
210
- meta = {"indexes": ["-scheduled_at", "jib"], "db_alias": "lgt_admin"}
211
-
212
-
213
- class UserCreditStatementDocument(Document):
214
- meta = {"indexes": [("user_id", "created_at"),
215
- ("user_id", "created_at", "action")], "db_alias": "lgt_admin"}
216
-
217
- user_id = ObjectIdField(required=True)
218
- created_at = DateTimeField(required=True)
219
- balance = IntField(required=True)
220
- action = StringField(required=True)
221
- lead_id = StringField(required=False)
222
- attributes = ListField(field=StringField(), required=False)
223
-
@@ -1,68 +0,0 @@
1
- from enum import Enum, IntFlag
2
-
3
-
4
- class DedicatedBotState(IntFlag):
5
- Operational = 0
6
- Stopped = 1
7
- ScheduledForDeletion = 2
8
-
9
-
10
- class UserAccountState(IntFlag):
11
- Operational = 0
12
- Suspended = 1
13
-
14
-
15
- class UserRole(str, Enum):
16
- ADMIN = 'admin'
17
- USER = 'user'
18
- MODERATOR = 'moderator'
19
-
20
-
21
- class BotType(str, Enum):
22
- DEDICATED_BOT = 'dedicated',
23
- LEADGURU_BOT = 'leadguru'
24
-
25
-
26
- class GoogleCloudFolder(str, Enum):
27
- SLACK_PROFILE_FILES = "Slack_profile"
28
- TICKET_FILES = "Ticket"
29
-
30
-
31
- class SourceType(str, Enum):
32
- SLACK = 'slack'
33
- DISCORD = 'discord'
34
-
35
-
36
- class BotUpdateEventType(str, Enum):
37
- NotDefined = 'NotDefined'
38
- BotAdded = 'BotAdded'
39
- BotDeleted = 'BotDeleted'
40
- BotUpdated = 'BotUpdated'
41
-
42
-
43
- class UserAction(str, Enum):
44
- PAUSE_CHANNEL = 'monitoring.pause.channel'
45
- PAUSE_SOURCE = 'monitoring.pause.source'
46
- UNPAUSE_CHANNEL = 'monitoring.unpause.channel'
47
- UNPAUSE_SOURCE = 'monitoring.unpause.source'
48
- STOP_CHANNEL = 'monitoring.stop.channel'
49
- STOP_SOURCE = 'monitoring.stop.source'
50
- START_CHANNEL = 'monitoring.start.channel'
51
- START_SOURCE = 'monitoring.start.source'
52
- LOGIN = 'login'
53
- LEAD_SAVE = 'lead.save'
54
- CHAT_MESSAGE = 'chat.message'
55
- ADMIN_CREDITS_ADDED = "admin-creds-added"
56
- ADMIN_CREDITS_SET = "admin-creds-set"
57
- INITIAL_CREDITS_SET = "initial-creds-set"
58
-
59
-
60
- class StatusConnection(str, Enum):
61
- IN_PROGRESS = 'In progress',
62
- COMPLETE = 'Complete',
63
- FAILED = 'Failed'
64
-
65
-
66
- class DefaultBoards(str, Enum):
67
- Inbox = 'Inbox',
68
- Primary = 'Primary board'
@@ -1,2 +0,0 @@
1
- def get_linkedin_search_contact(name: str):
2
- return f"https://www.linkedin.com/search/results/all/?keywords={name}&origin=GLOBAL_SEARCH_HEADER&sid=u%40F"