添加新的逻辑

main
RogerWork 1 year ago
parent 4058b24f1a
commit 3f65f15a7f
  1. 28
      orm/blue_forecast.py
  2. 7
      orm/db.py
  3. 1
      orm/red_forecast.py

@ -8,6 +8,10 @@ def get_all_data():
return db_history_get_all_data()
def get_all_data_desc():
return db_history_get_all_data('desc')
# 获取所有篮球的统计数据
def get_all_blue(_all_data):
all_blue = dict()
@ -120,19 +124,35 @@ def insert_blue_data(_all_data, _history, _prv, _post, _num):
print("数据插入失败")
def print_blue_data(_history, _prv_five, _post_five, _prv_three, _post_three):
def get_interval_blue():
blue_dict = {}
_all_data_desc = get_all_data_desc()
_last_blue = _all_data_desc[0].get('blue')
_blue_list = [_data['blue'] for _data in _all_data_desc]
for n in range(len(_blue_list)):
if _blue_list[n] not in blue_dict.keys():
blue_dict[_blue_list[n]] = n
if len(blue_dict.keys()) == 16:
break
# print(dict_sort(blue_dict, 'val', True))
return dict_sort(blue_dict, 'val', True)
def print_blue_data(_history, _prv_five, _post_five, _prv_three, _post_three, _interval):
_history_list = list(_history.items())
_prv_five_list = list(_prv_five.items())
_post_five_list = list(_post_five.items())
_prv_three_list = list(_prv_three.items())
_post_three_list = list(_post_three.items())
_interval_list = list(_interval.items())
print('篮球数据表:')
for i in range(16):
print(f"{_history_list[i][0]} [{_history_list[i][1]}]\t"
f" {_prv_five_list[i][0]} [{_prv_five_list[i][1]}]\t"
f"{_post_five_list[i][0]} [{_post_five_list[i][1]}]\t"
f"{_prv_three_list[i][0]} [{_prv_three_list[i][1]}]\t"
f"{_post_three_list[i][0]} [{_post_three_list[i][1]}]")
f"{_post_three_list[i][0]} [{_post_three_list[i][1]}]\t"
f"{_interval_list[i][0]} [{_interval_list[i][1]}]")
def forecast_blue():
@ -142,9 +162,10 @@ def forecast_blue():
post_five = get_blue_forecast(get_all_data(), 'post', 5)
prv_three = get_blue_forecast(get_all_data(), 'prv', 3)
post_three = get_blue_forecast(get_all_data(), 'post', 3)
interval_blue = get_interval_blue()
insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_five), json.dumps(post_five), 5)
insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_three), json.dumps(post_three), 3)
print_blue_data(history_total, prv_five, post_five, prv_three, post_three)
print_blue_data(history_total, prv_five, post_five, prv_three, post_three, interval_blue)
if __name__ == "__main__":
@ -157,4 +178,5 @@ if __name__ == "__main__":
# insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_five), json.dumps(post_five), 5)
# insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_three), json.dumps(post_three), 3)
# print_blue_data(history_total, prv_five, post_five, prv_three, post_three)
# get_interval_blue()
pass

@ -23,9 +23,12 @@ def db_history_get_last_data():
return False
def db_history_get_all_data():
def db_history_get_all_data(_order='asc'):
try:
get_all_data_stmt = select(History).order_by(asc(History.id))
if _order == 'asc':
get_all_data_stmt = select(History).order_by(asc(History.id))
else:
get_all_data_stmt = select(History).order_by(desc(History.id))
all_data_result = db_session.execute(get_all_data_stmt).scalars()
return history_scalars(all_data_result)
except Exception as e:

@ -24,7 +24,6 @@ def get_all_red(_all_data):
_all_red_dict[_red] += 1
else:
_all_red_dict[_red] = 1
return _all_red_dict

Loading…
Cancel
Save