Skip to content

Commit

Permalink
Merge branch 'master' into remove-python-fb-page-insights-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-W authored Oct 8, 2023
2 parents 5230fda + ba1151b commit e980c11
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions dags/app/finance_bot/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pandas as pd
import pygsheets
import requests
from airflow.models import Variable
from app import discord
from google.cloud import bigquery

Expand All @@ -20,11 +21,13 @@ def main() -> None:
# link to bigquery and write xls file
write_to_bigquery(df_diff)
# push to discord
webhook_url = os.getenv("discord_data_stratagy_webhook")
username = "財務機器人"
msg = refine_diff_df_to_string(df_diff)
if msg != "no data":
discord.send_webhook_message(webhook_url, username, msg)
kwargs = {
"webhook_url": Variable.get("discord_data_stratagy_webhook"),
"username": "財務機器人",
"msg": refine_diff_df_to_string(df_diff),
}
if kwargs["msg"] != "no data":
discord.send_webhook_message(**kwargs)


def df_difference(df_xls, df_bigquery) -> pd.DataFrame:
Expand All @@ -50,7 +53,7 @@ def read_bigquery_to_df() -> pd.DataFrame:

def read_google_xls_to_df() -> pd.DataFrame:
gc = pygsheets.authorize(service_file=os.getenv("GOOGLE_APPLICATION_CREDENTIALS"))
sheet = gc.open_by_url(os.getenv("finance_xls_path"))
sheet = gc.open_by_url(Variable.get("finance_xls_path"))
wks = sheet.sheet1
df = wks.get_as_df(include_tailing_empty=False)
df.replace("", np.nan, inplace=True)
Expand Down

0 comments on commit e980c11

Please sign in to comment.