data_stat_daily.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from model.DateUtils import DateUtils
  2. from data_stat_task import *
  3. from sync_to_ck_task import *
  4. du = DateUtils()
  5. from model.DingTalkUtils import DingTalkUtils
  6. from app.etl.dm.dm_pitcher_daily_overview import dm_pitcher_daily_overview
  7. yestoday = du.get_n_days(-1)
  8. today = du.get_n_days(0)
  9. def run(ymd):
  10. try:
  11. # 公众号元数据
  12. channel_by_account_daily(ymd)
  13. channel_info_daily(ymd)
  14. # 清洗订单表-同步到ck
  15. ods_order(ymd)
  16. order_sync_ck(ymd)
  17. # 公众号维度数据-同步到ck
  18. dw_daily_channel_cost(ymd)
  19. dw_order_channel_cost_sync_ck(ymd)
  20. dw_channel_daily_total(ymd)
  21. except Exception as e:
  22. DingTalkUtils.send("数据ETL出错:",'18860455786')
  23. def run_order_history():
  24. """当order表跑了历史的数据,要从这历史数据的最早时间跑此任务流"""
  25. for i in du.getDateLists('2020-11-01',du.get_n_days(0)):
  26. print(i)
  27. ods_order(i)
  28. order_sync_ck(i)
  29. dw_channel_daily_total(i)
  30. dw_daily_channel()
  31. print('ok')
  32. def run_cost_history():
  33. "cost 重跑后,跑此任务流"
  34. for i in du.getDateLists('2020-11-01',du.get_n_days(0)):
  35. print(i)
  36. dw_daily_channel_cost(i)
  37. dw_order_channel_cost_sync_ck(i)
  38. dw_channel_daily_total(i)
  39. dw_daily_channel()
  40. def main():
  41. run(yestoday)
  42. dw_daily_channel()
  43. dm_pitcher_daily_overview()
  44. if __name__ == '__main__':
  45. # main()
  46. run_order_history()