task.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import threading
  2. from app.api_data.tx_ad_cost.get_cost_older import old_cost_hourly, old_cost_daily
  3. from app.etl.sync_to_ck_task import order_sync_ck
  4. from app.api_data.tx_ad_cost import get_cost_older
  5. from app.etl.data_stat_run import do_cost
  6. from app.api_data.platform_order.order_data_change import insert_order_data_daily, insert_order_data_hourly
  7. from model.DateUtils import DateUtils
  8. from app.game_data_sum.data_sum import change_data_style_daily, change_data_style_hourly
  9. du = DateUtils()
  10. def hourly():
  11. t10 = threading.Thread(target=change_data_style_hourly)
  12. t11 = threading.Thread(target=old_cost_hourly)
  13. # t12 = threading.Thread(target=insert_order_data_hourly)
  14. t10.start()
  15. t10.join()
  16. t11.start()
  17. t11.join()
  18. # t12.start()
  19. # t12.join()
  20. def daily():
  21. t10 = threading.Thread(target=change_data_style_daily)
  22. t11 = threading.Thread(target=old_cost_daily, args=())
  23. # t12 = threading.Thread(target=insert_order_data_daily)
  24. t10.start()
  25. t10.join()
  26. t11.start()
  27. t11.join()
  28. # t12.start()
  29. # t12.join()
  30. def cost_yestoday_repair():
  31. dt = du.get_n_days(-1)
  32. get_cost_older.run(dt, dt)
  33. do_cost(dt, dt)
  34. if __name__ == '__main__':
  35. import logging
  36. from logging import handlers
  37. logging.basicConfig(
  38. handlers=[
  39. logging.handlers.RotatingFileHandler('task.log',
  40. maxBytes=10 * 1024 * 1024,
  41. backupCount=5,
  42. encoding='utf-8')
  43. , logging.StreamHandler() # 供输出使用
  44. ],
  45. level=logging.INFO,
  46. format="%(asctime)s - %(levelname)s %(filename)s %(funcName)s %(lineno)s - %(message)s"
  47. )
  48. # hourly()
  49. # cost_yestoday_repair()
  50. daily()