sql_help.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import os
  2. import sys
  3. import datetime
  4. sys.path.append(os.getcwd())
  5. from datetime import datetime
  6. from common import MysqlHelper
  7. class sql():
  8. # 获取音画美文类数量-抖音
  9. @classmethod
  10. def get_dy_yinmei_account_id(cls):
  11. current_time = datetime.now()
  12. formatted_time = current_time.strftime("%Y-%m-%d")
  13. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 0 GROUP BY audio, account_id) AS subquery;"""
  14. count = MysqlHelper.get_values(count, "prod")
  15. if count == None:
  16. count = 0
  17. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  18. return int(count)
  19. # 获取音画美文类数量-快手
  20. @classmethod
  21. def get_ks_yinmei_account_id(cls):
  22. current_time = datetime.now()
  23. formatted_time = current_time.strftime("%Y-%m-%d")
  24. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 2 GROUP BY audio, account_id) AS subquery;"""
  25. count = MysqlHelper.get_values(count, "prod")
  26. if count == None:
  27. count = 0
  28. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  29. return int(count)
  30. # 获取口播类数量
  31. @classmethod
  32. def get_koubo_account_id(cls):
  33. current_time = datetime.now()
  34. formatted_time = current_time.strftime("%Y-%m-%d")
  35. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 1 GROUP BY audio, account_id) AS subquery;"""
  36. count = MysqlHelper.get_values(count, "prod")
  37. if count == None:
  38. count = 0
  39. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  40. return int(count)
  41. # 获取口播类-节日数量
  42. @classmethod
  43. def get_jieri_account_id(cls):
  44. current_time = datetime.now()
  45. formatted_time = current_time.strftime("%Y-%m-%d")
  46. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 3 GROUP BY audio, account_id) AS subquery;"""
  47. count = MysqlHelper.get_values(count, "prod")
  48. if count == None:
  49. count = 0
  50. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  51. return int(count)
  52. # 获取春节自制-节日数量
  53. @classmethod
  54. def get_chunjie_zizhi_account_id(cls):
  55. current_time = datetime.now()
  56. formatted_time = current_time.strftime("%Y-%m-%d")
  57. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 4 GROUP BY audio, account_id) AS subquery;"""
  58. count = MysqlHelper.get_values(count, "prod")
  59. if count == None:
  60. count = 0
  61. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  62. return int(count)
  63. # 获取抖音拼接数量
  64. @classmethod
  65. def get_pjdouyin_account_id(cls):
  66. current_time = datetime.now()
  67. formatted_time = current_time.strftime("%Y-%m-%d")
  68. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 6 GROUP BY audio, account_id) AS subquery;"""
  69. count = MysqlHelper.get_values(count, "prod")
  70. if count == None:
  71. count = 0
  72. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  73. return int(count)
  74. # 获取快手拼接数量
  75. @classmethod
  76. def get_ksdouyin_account_id(cls):
  77. current_time = datetime.now()
  78. formatted_time = current_time.strftime("%Y-%m-%d")
  79. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 5 GROUP BY audio, account_id) AS subquery;"""
  80. count = MysqlHelper.get_values(count, "prod")
  81. if count == None:
  82. count = 0
  83. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  84. return int(count)
  85. @classmethod
  86. def update_inconformity_id_list(cls, id):
  87. update_sql = f""" update video_url set status={0} WHERE video_id ="{id}" """
  88. MysqlHelper.update_values(
  89. sql=update_sql,
  90. env="prod",
  91. machine="",
  92. )