diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/citco_ops/utils.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/python/citco_ops/utils.py b/python/citco_ops/utils.py index c07f8cb9..b926f700 100644 --- a/python/citco_ops/utils.py +++ b/python/citco_ops/utils.py @@ -7,6 +7,7 @@ from serenitas.ops.trade_dataclasses import Deal from serenitas.utils.exchange import ExchangeMessage from psycopg.errors import UniqueViolation from exchangelib import HTMLBody +from tabulate import tabulate logger = logging.getLogger(__name__) @@ -116,7 +117,7 @@ class CitcoSubmission(Deal, deal_type=None, table_name="citco_submission"): em = ExchangeMessage() em.send_email( f"(CITCO) UPLOAD {'SUCCESS' if cls._insert_queue[0][5] else 'FAILED'}", - "\n".join(map(str, cls._insert_queue)), + cls._format(), ( "fyu@lmcg.com", "ghorel@lmcg.com", @@ -126,6 +127,37 @@ class CitcoSubmission(Deal, deal_type=None, table_name="citco_submission"): finally: cls._insert_queue.clear() + @classmethod + def _format(cls): + t = tabulate( + [upload for upload in cls._insert_queue], + headers=[ + "file_name", + "upload_type", + "citco_id", + "serenitas_id", + "commit_time", + "processed", + ], + tablefmt="unsafehtml", + ) + html = HTMLBody( + f""" + <html> + <head> + <style> + table, th, td {{ border: 1px solid black; border-collapse: collapse;}} + th, td {{ padding: 5px; }} + </style> + </head> + <body> + {t} + </body> + </html> + """ + ) + return html + _recipients = { "ISOSEL": ( |
