22-06-2026 1st commit

This commit is contained in:
Ankit Malik
2026-06-22 13:08:26 +05:30
parent 2ead99553f
commit e1bd387849
18 changed files with 949 additions and 11547 deletions
+52 -5
View File
@@ -242,7 +242,18 @@ def fetch_OQaD(
on=["empid", "visitdate"],
how="inner",
)
empids=matched["empid"].to_list()
if matched.is_empty():
empids=[0]
log.warning(
"%s Matched df in OQaD returned no rows",
table_name,
)
else:
empids=matched["empid"].to_list()
log.info(f"Fetched {len(empids):,} matched empids fetched for OQAD ")
@@ -418,9 +429,9 @@ def fetch_Login( engine: Engine,
if not mids:
log.warning("No MIDs — nothing to fetch.")
return pl.DataFrame()
# if not mids:
# log.warning("No MIDs — nothing to fetch.")
# return pl.DataFrame()
mid_list = ",".join(str(mid) for mid in mids)
log.info(f"Start Fetching data for these {len(mids):} MIDs or based on this date {run_date}")
@@ -430,7 +441,7 @@ def fetch_Login( engine: Engine,
sql_template = f.read()
sql = sql_template.format(
mid_list=mid_list,
# mid_list=mid_list,
run_date=run_date.strftime("%Y-%m-%d")
)
log.info(f"Fetching data for {len(mids):,} MIDs")
@@ -673,4 +684,40 @@ def fetch_Web_Logins( engine: Engine,
)
log.info(f"Fetched {len(df):,} rows from SQL Server")
return df
def fetch_Promotion(
engine: Engine,
table_name: str,
table_type: str,
mids: list[int],
run_date: date
) -> pl.DataFrame:
if not mids:
log.warning("No MIDs — nothing to fetch.")
return pl.DataFrame()
mid_list = ",".join(str(mid) for mid in mids)
sql_file = Path("src") / "sql" / f"{table_type.lower()}" / f"{table_name}.sql"
with open(sql_file, "r", encoding="utf-8") as f:
sql_template = f.read()
sql = sql_template.format(
mid_list=mid_list,
run_date=run_date.strftime("%Y-%m-%d")
)
log.info(f"Fetching data for {len(mids):,} MIDs")
df = pl.read_database(
query=sql,
connection=engine
)
log.info(f"Fetched {len(df):,} rows from SQL Server")
return df