prettier emails
This commit is contained in:
@@ -22,7 +22,7 @@ SOURCES = ["plato", "sounds"]
|
||||
logger = structlog.get_logger()
|
||||
|
||||
daily_partitions_def = dg.DailyPartitionsDefinition(
|
||||
start_date="2024-09-01", end_offset=1, timezone=os.environ["TZ"]
|
||||
start_date="2024-09-01", end_offset=1, timezone=os.environ.get("TZ", "UTC")
|
||||
)
|
||||
multi_partitions_def = dg.MultiPartitionsDefinition(
|
||||
{
|
||||
@@ -235,13 +235,32 @@ def good_deals(
|
||||
yield dg.Output(Deal.DataFrame(filtered_df))
|
||||
|
||||
lines = []
|
||||
lines.append(
|
||||
"""
|
||||
<div style="font-family: Arial, sans-serif; background-color: #f4f4f4; padding: 20px;">
|
||||
<h2 style="color: #333;">🎶 New Music Releases</h2>
|
||||
"""
|
||||
)
|
||||
|
||||
# Each item
|
||||
for data in filtered_df.head(10).iter_rows(named=True):
|
||||
row = SimpleNamespace(**data)
|
||||
lines.append(f'<a href="https://www.platomania.nl{row.url}"><h1>NEW</h1></a>')
|
||||
lines.append("<ul>")
|
||||
lines.append(f"<li>[artist] {row.artist}</li>")
|
||||
lines.append(f"<li>[title] {row.title}</li>")
|
||||
lines.append(f"<li>[price] {row.price}</li>")
|
||||
lines.append(f"<li>[release] {row.release}</li>")
|
||||
lines.append("</ul>")
|
||||
lines.append(
|
||||
f"""
|
||||
<div style="background-color: #fff; margin-bottom: 20px; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);">
|
||||
<a href="https://www.platomania.nl{row.url}" style="text-decoration: none; color: #1a73e8;">
|
||||
<h3 style="margin: 0 0 10px;">🆕 {row.artist} - {row.title}</h3>
|
||||
</a>
|
||||
<ul style="list-style: none; padding-left: 0; margin: 0;">
|
||||
<li><strong>Artist:</strong> {row.artist}</li>
|
||||
<li><strong>Title:</strong> {row.title}</li>
|
||||
<li><strong>Price:</strong> €{row.price}</li>
|
||||
<li><strong>Release Date:</strong> {row.release}</li>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
# Email footer
|
||||
lines.append("</div>")
|
||||
email_service.send_email("\n".join(lines))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
import assets
|
||||
from dagster_polars import PolarsParquetIOManager
|
||||
from icecream import install
|
||||
@@ -17,7 +19,9 @@ definitions = dg.Definitions(
|
||||
for asset in dg.load_assets_from_modules([assets])
|
||||
],
|
||||
resources={
|
||||
"polars_parquet_io_manager": PolarsParquetIOManager(base_dir="/storage/vinyl"),
|
||||
"polars_parquet_io_manager": PolarsParquetIOManager(
|
||||
base_dir=os.environ.get("STORAGE_DIR", "/storage") + "/vinyl"
|
||||
),
|
||||
"email_service": EmailService(
|
||||
smtp_server=dg.EnvVar("SMTP_SERVER"),
|
||||
smtp_port=dg.EnvVar.int("SMTP_PORT"),
|
||||
|
||||
@@ -3,7 +3,7 @@ from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from assets import cleaned_deals, deals, good_deals, new_deals, works
|
||||
from definitions import definitions
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
from jobs import check_partitions_job
|
||||
|
||||
import dagster as dg
|
||||
@@ -31,6 +31,9 @@ def test_deals(resources: dict[str, Any], source="sounds", date: str = None):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv(find_dotenv())
|
||||
from definitions import definitions
|
||||
|
||||
run = 6
|
||||
resources = definitions.resources
|
||||
source = "plato"
|
||||
|
||||
Reference in New Issue
Block a user