14-06-26 1st comit
This commit is contained in:
@@ -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,
|
||||
)
|
||||
Reference in New Issue
Block a user