14-06-26 1st comit

This commit is contained in:
Ankit Malik
2026-06-15 12:44:13 +05:30
parent 418a8847b2
commit 166a2a1d19
14 changed files with 1981 additions and 80 deletions
+29 -3
View File
@@ -19,7 +19,7 @@ from db_con.connection import *
def collect_mids(engine: Engine, target_date: date) -> list[int]:
def MID_TABLE_COV(engine: Engine, target_date: date) -> list[int]:
sql = text("""
SELECT MID FROM OneApp_KelloggsMT.dbo.T_StoreCoverage
@@ -30,9 +30,35 @@ def collect_mids(engine: Engine, target_date: date) -> list[int]:
""")
log.info(f"Collecting MIDs for: {target_date}")
with engine.connect() as conn:
result = conn.execute(sql, {"target_date": target_date})
mids = [row[0] for row in result.fetchall()]
log.info(f"Found {len(mids):,} MIDs")
return mids
return mids
def MID_TABLE_COV1(
engine: Engine,
target_date: date,
) -> pl.DataFrame:
query = f"""
SELECT
EmpId,
CAST(VisitDate AS DATE) AS VisitDate
FROM OneApp_KelloggsMT.dbo.T_OQAD
WHERE CAST(CreateDate AS DATE) = '{target_date}'
UNION
SELECT
EmpId,
CAST(VisitDate AS DATE) AS VisitDate
FROM OneApp_KelloggsMT.dbo.T_OQAD
WHERE CAST(UpdateDate AS DATE) = '{target_date}'
"""
return pl.read_database(
query=query,
connection=engine,
)