teams-alerter 0.2.8__tar.gz → 0.2.9__tar.gz
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.
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/PKG-INFO +1 -1
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/pyproject.toml +1 -1
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter/utils.py +26 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter.egg-info/PKG-INFO +1 -1
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/tests/test_core.py +51 -51
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/README.md +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/setup.cfg +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter/__init__.py +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter/core.py +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter.egg-info/SOURCES.txt +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter.egg-info/dependency_links.txt +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter.egg-info/requires.txt +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/teams_alerter.egg-info/top_level.txt +0 -0
- {teams_alerter-0.2.8 → teams_alerter-0.2.9}/tests/__init__.py +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "teams-alerter"
|
7
|
-
version = "0.2.
|
7
|
+
version = "0.2.9"
|
8
8
|
description = "Module pour envoyer des alertes Teams via Pub/Sub"
|
9
9
|
authors = [{ name = "Toki", email = "t.bakotondrabe-ext@paris-turf.com" }]
|
10
10
|
readme = "README.md"
|
@@ -66,6 +66,8 @@ def format_email_template(email_object, email_messages, table_data, app_name):
|
|
66
66
|
</td>
|
67
67
|
</tr>
|
68
68
|
|
69
|
+
{build_snippet_html_part(table_data, app_name) if table_data else ""}
|
70
|
+
|
69
71
|
<tr>
|
70
72
|
<td style="padding:0 24px 16px 24px; font-family:Segoe UI, Arial, sans-serif; font-size:14px; line-height:20px; color:#4b5563;">
|
71
73
|
Cordialement,
|
@@ -173,3 +175,27 @@ def is_json(value):
|
|
173
175
|
return True
|
174
176
|
except json.JSONDecodeError:
|
175
177
|
return False
|
178
|
+
|
179
|
+
|
180
|
+
def build_snippet_html_part(table_data: list, app_name: str):
|
181
|
+
content = ""
|
182
|
+
|
183
|
+
if app_name == "health_check_check_horses_stats":
|
184
|
+
content = """
|
185
|
+
<div style="font-weight:bold;margin-bottom:6px;">Liste des ids manquants dans stats_processing_queue</div>
|
186
|
+
<div style="background:#0b1021;color:#e6e6e6;padding:12px;border-radius:4px;font-family:monospace;font-size:13px;line-height:1.5;white-space:pre;">
|
187
|
+
"""
|
188
|
+
for row in table_data[1:]:
|
189
|
+
content += f"SELECT * FROM ps_force_relaunch_stat_cheval_apres_course('{row[0]}');\n"
|
190
|
+
content += "</div>"
|
191
|
+
|
192
|
+
elif app_name == "health_check_check_partants_data":
|
193
|
+
content = """
|
194
|
+
<div style="font-weight:bold;margin-bottom:6px;">Liste des requêtes pour relancer l'aggregation</div>
|
195
|
+
<div style="background:#0b1021;color:#e6e6e6;padding:12px;border-radius:4px;font-family:monospace;font-size:13px;line-height:1.5;white-space:pre;">
|
196
|
+
"""
|
197
|
+
for row in table_data:
|
198
|
+
content += f"SELECT * FROM ps_force_relaunch_transaction('tb_course','{row[0]}', false);\n"
|
199
|
+
content += "</div>"
|
200
|
+
|
201
|
+
return content
|
@@ -1,51 +1,51 @@
|
|
1
|
-
import pytest
|
2
|
-
import os
|
3
|
-
import json
|
4
|
-
|
5
|
-
from teams_alerter.core import TeamsAlerter
|
6
|
-
|
7
|
-
|
8
|
-
def test_error_handler():
|
9
|
-
env = "dev"
|
10
|
-
ERROR_UTILS = {
|
11
|
-
"env": env,
|
12
|
-
"app_project_id": os.environ.get("ERROR_HANDLER_APP_PROJECT_ID", "betin-horse-datastream-" + env),
|
13
|
-
"topic_project_id": os.environ.get("ERROR_HANDLER_TOPIC_PROJECT_ID", "betin-horse-datastream-" + env),
|
14
|
-
"topic_id": os.environ.get("ERROR_HANDLER_TOPIC_ID", "topic-datastream-errors-" + env),
|
15
|
-
"app_name": "health_check_check_horses_stats",
|
16
|
-
"teams_channel": "datastream-alerts-" + env,
|
17
|
-
}
|
18
|
-
diffs_list = [
|
19
|
-
{
|
20
|
-
"idCheval": 1338148,
|
21
|
-
"champ": "formFigs",
|
22
|
-
"postgres": '<span style="background-color:yellow; color:#000;">5a</span> 8a 8a 3a (24) 13a 12a 9a 10a Da 7a 7m 9a 10a 8m 6a 0a Da 10a 7a 7a (23) 11a 1a 2a 5a 10a 4a Aa 3a 10a Aa 3a 10a 2a 3a 3a 3a Da 4a 7a (22) 7a 3a 3a 1a 12a 6a 1a 1a 2a 7a 1a 4a 4a 1a 6a 1a 4a 10a (21) 14a 4a 5a 4a 1a 3a 2a 4a 7a 3a 5a 4a 6a 2a 2a 7a 7a 7a (20) 1a 1a 2a 4a 6a 1a 3a 5a 1a 1a 4a 1a 3a 4a 2a 2a (19) 4a 5a Da Da 4a 5Da 3a 5a 1a 4a (18) Da Da 5a 2a',
|
23
|
-
"mongo": "8a 8a 3a (24) 13a 12a 9a 10a Da 7a 7m 9a 10a 8m 6a 0a Da 10a 7a 7a (23) 11a 1a 2a 5a 10a 4a Aa 3a 10a Aa 3a 10a 2a 3a 3a 3a Da 4a 7a (22) 7a 3a 3a 1a 12a 6a 1a 1a 2a 7a 1a 4a 4a 1a 6a 1a 4a 10a (21) 14a 4a 5a 4a 1a 3a 2a 4a 7a 3a 5a 4a 6a 2a 2a 7a 7a 7a (20) 1a 1a 2a 4a 6a 1a 3a 5a 1a 1a 4a 1a 3a 4a 2a 2a (19) 4a 5a Da Da 4a 5Da 3a 5a 1a 4a (18) Da Da 5a 2a",
|
24
|
-
"difference": "5a manquants dans Mongo",
|
25
|
-
},
|
26
|
-
{
|
27
|
-
"idCheval": 1338148,
|
28
|
-
"champ": "totalPrize",
|
29
|
-
"postgres": 308670,
|
30
|
-
"mongo": 304920,
|
31
|
-
"difference": "3750 de moins dans Mongo",
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"idCheval": 1343727,
|
35
|
-
"champ": "formFigs",
|
36
|
-
"postgres": '<span style="background-color:yellow; color:#000;">4a</span> <span style="background-color:yellow; color:#000;">4a</span> 4m 9m 7a Da 9a 3m (24) 6a 1a 1a 5a 6a 1a Da 4a 6a 4a 3a 5a 2a 0a (23) 9a 6a Da Aa 1a 0a 3a Da 4m 7a 7a Da 3a 4Dista 5a 9a (22) 13a 11a 6a Aa 4a 8a 3a 2a 3a 4a 4a 3a 6a 8a (21) 1a Da 11a 9a 6a 3a 3a 5a 3a Da 2a 4a 1a 11a Da 6a 2a (20) 1a 11a Da 3a Aa 3a 3a 9a 1a 8a 5a (19) 4a 2a 5a 4a 1a 7a',
|
37
|
-
"mongo": "4m 9m 7a Da 9a 3m (24) 6a 1a 1a 5a 6a 1a Da 4a 6a 4a 3a 5a 2a 0a (23) 9a 6a Da Aa 1a 0a 3a Da 4m 7a 7a Da 3a 4Dista 5a 9a (22) 13a 11a 6a Aa 4a 8a 3a 2a 3a 4a 4a 3a 6a 8a (21) 1a Da 11a 9a 6a 3a 3a 5a 3a Da 2a 4a 1a 11a Da 6a 2a (20) 1a 11a Da 3a Aa 3a 3a 9a 1a 8a 5a (19) 4a 2a 5a 4a 1a 7a",
|
38
|
-
"difference": "4a 4a manquants dans Mongo",
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"idCheval": 1343727,
|
42
|
-
"champ": "totalPrize",
|
43
|
-
"postgres": 163935,
|
44
|
-
"mongo": 159775,
|
45
|
-
"difference": "4160 de moins dans Mongo",
|
46
|
-
},
|
47
|
-
]
|
48
|
-
error = ValueError(
|
49
|
-
ValueError(json.dumps({"data": diffs_list, "message": f"[Vérification horses_stats du 2025-08-29]"}))
|
50
|
-
)
|
51
|
-
TeamsAlerter.handle_error(error, ERROR_UTILS)
|
1
|
+
import pytest
|
2
|
+
import os
|
3
|
+
import json
|
4
|
+
|
5
|
+
from teams_alerter.core import TeamsAlerter
|
6
|
+
|
7
|
+
|
8
|
+
def test_error_handler():
|
9
|
+
env = "dev"
|
10
|
+
ERROR_UTILS = {
|
11
|
+
"env": env,
|
12
|
+
"app_project_id": os.environ.get("ERROR_HANDLER_APP_PROJECT_ID", "betin-horse-datastream-" + env),
|
13
|
+
"topic_project_id": os.environ.get("ERROR_HANDLER_TOPIC_PROJECT_ID", "betin-horse-datastream-" + env),
|
14
|
+
"topic_id": os.environ.get("ERROR_HANDLER_TOPIC_ID", "topic-datastream-errors-" + env),
|
15
|
+
"app_name": "health_check_check_horses_stats",
|
16
|
+
"teams_channel": "datastream-alerts-" + env,
|
17
|
+
}
|
18
|
+
diffs_list = [
|
19
|
+
{
|
20
|
+
"idCheval": 1338148,
|
21
|
+
"champ": "formFigs",
|
22
|
+
"postgres": '<span style="background-color:yellow; color:#000;">5a</span> 8a 8a 3a (24) 13a 12a 9a 10a Da 7a 7m 9a 10a 8m 6a 0a Da 10a 7a 7a (23) 11a 1a 2a 5a 10a 4a Aa 3a 10a Aa 3a 10a 2a 3a 3a 3a Da 4a 7a (22) 7a 3a 3a 1a 12a 6a 1a 1a 2a 7a 1a 4a 4a 1a 6a 1a 4a 10a (21) 14a 4a 5a 4a 1a 3a 2a 4a 7a 3a 5a 4a 6a 2a 2a 7a 7a 7a (20) 1a 1a 2a 4a 6a 1a 3a 5a 1a 1a 4a 1a 3a 4a 2a 2a (19) 4a 5a Da Da 4a 5Da 3a 5a 1a 4a (18) Da Da 5a 2a',
|
23
|
+
"mongo": "8a 8a 3a (24) 13a 12a 9a 10a Da 7a 7m 9a 10a 8m 6a 0a Da 10a 7a 7a (23) 11a 1a 2a 5a 10a 4a Aa 3a 10a Aa 3a 10a 2a 3a 3a 3a Da 4a 7a (22) 7a 3a 3a 1a 12a 6a 1a 1a 2a 7a 1a 4a 4a 1a 6a 1a 4a 10a (21) 14a 4a 5a 4a 1a 3a 2a 4a 7a 3a 5a 4a 6a 2a 2a 7a 7a 7a (20) 1a 1a 2a 4a 6a 1a 3a 5a 1a 1a 4a 1a 3a 4a 2a 2a (19) 4a 5a Da Da 4a 5Da 3a 5a 1a 4a (18) Da Da 5a 2a",
|
24
|
+
"difference": "5a manquants dans Mongo",
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"idCheval": 1338148,
|
28
|
+
"champ": "totalPrize",
|
29
|
+
"postgres": 308670,
|
30
|
+
"mongo": 304920,
|
31
|
+
"difference": "3750 de moins dans Mongo",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"idCheval": 1343727,
|
35
|
+
"champ": "formFigs",
|
36
|
+
"postgres": '<span style="background-color:yellow; color:#000;">4a</span> <span style="background-color:yellow; color:#000;">4a</span> 4m 9m 7a Da 9a 3m (24) 6a 1a 1a 5a 6a 1a Da 4a 6a 4a 3a 5a 2a 0a (23) 9a 6a Da Aa 1a 0a 3a Da 4m 7a 7a Da 3a 4Dista 5a 9a (22) 13a 11a 6a Aa 4a 8a 3a 2a 3a 4a 4a 3a 6a 8a (21) 1a Da 11a 9a 6a 3a 3a 5a 3a Da 2a 4a 1a 11a Da 6a 2a (20) 1a 11a Da 3a Aa 3a 3a 9a 1a 8a 5a (19) 4a 2a 5a 4a 1a 7a',
|
37
|
+
"mongo": "4m 9m 7a Da 9a 3m (24) 6a 1a 1a 5a 6a 1a Da 4a 6a 4a 3a 5a 2a 0a (23) 9a 6a Da Aa 1a 0a 3a Da 4m 7a 7a Da 3a 4Dista 5a 9a (22) 13a 11a 6a Aa 4a 8a 3a 2a 3a 4a 4a 3a 6a 8a (21) 1a Da 11a 9a 6a 3a 3a 5a 3a Da 2a 4a 1a 11a Da 6a 2a (20) 1a 11a Da 3a Aa 3a 3a 9a 1a 8a 5a (19) 4a 2a 5a 4a 1a 7a",
|
38
|
+
"difference": "4a 4a manquants dans Mongo",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"idCheval": 1343727,
|
42
|
+
"champ": "totalPrize",
|
43
|
+
"postgres": 163935,
|
44
|
+
"mongo": 159775,
|
45
|
+
"difference": "4160 de moins dans Mongo",
|
46
|
+
},
|
47
|
+
]
|
48
|
+
error = ValueError(
|
49
|
+
ValueError(json.dumps({"data": diffs_list, "message": f"[Vérification horses_stats du 2025-08-29]"}))
|
50
|
+
)
|
51
|
+
TeamsAlerter.handle_error(error, ERROR_UTILS)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|