修复一些问题

main
roger_home_pc 1 year ago
parent b0199e676a
commit 4058b24f1a
  1. 3
      orm/db.py
  2. 30
      orm/real_index.py
  3. 2
      orm/red_forecast.py

@ -169,7 +169,8 @@ def db_index_get_last_date_id(_type):
index_result = db_session.execute(index_stmt).scalars()
date_id_list = []
for row in index_result:
date_id_list.append(row.date_id)
print(row)
date_id_list.append(row)
return date_id_list

@ -65,16 +65,15 @@ def update_real_data():
}
db_red_update(_id, red_date_id, update_data)
# 插入 IndexGroup index_group
insert_index_group(
{'dateId': red_date_id, 'type': 'history', 'index_group': json.dumps(history_index_group)})
insert_index_group({'dateId': red_date_id, 'type': 'last', 'index_group': json.dumps(last_index_group)})
insert_index_group(red_date_id, 'history', json.dumps(history_index_group))
insert_index_group(red_date_id, 'last', json.dumps(last_index_group))
if blue_date_id['five'] == old_history_date_id:
# 插入 real_blue, prv_index, post_index, history_index
real_blue = all_data[-1]['blue']
forecast_blue_data = db_blue_get_data_by_date_id(blue_date_id['five'], 5)
for data in forecast_blue_data:
_id = data['id']
if blue_date_id['five'] == old_history_date_id:
# 插入 real_blue, prv_index, post_index, history_index
real_blue = all_data[-1]['blue']
forecast_blue_data = db_blue_get_data_by_date_id(blue_date_id['five'], 5)
for data in forecast_blue_data:
_id = data['id']
prv_index = general_blue_index(real_blue, json.loads(data['prv']))
post_index = general_blue_index(real_blue, json.loads(data['post']))
history_index = general_blue_index(real_blue, json.loads(data['history']))
@ -86,11 +85,11 @@ def update_real_data():
}
db_blue_update(blue_date_id['five'], update_data, _id, 5)
if blue_date_id['three'] == old_history_date_id:
real_blue = all_data[-1]['blue']
forecast_blue_data = db_blue_get_data_by_date_id(blue_date_id['three'], 3)
for data in forecast_blue_data:
_id = data['id']
if blue_date_id['three'] == old_history_date_id:
real_blue = all_data[-1]['blue']
forecast_blue_data = db_blue_get_data_by_date_id(blue_date_id['three'], 3)
for data in forecast_blue_data:
_id = data['id']
prv_index = general_blue_index(real_blue, json.loads(data['prv']))
post_index = general_blue_index(real_blue, json.loads(data['post']))
history_index = general_blue_index(real_blue, json.loads(data['history']))
@ -102,8 +101,9 @@ def update_real_data():
}
db_blue_update(blue_date_id['three'], update_data, _id, 3)
# 插入预测数据
# 插入预测数据
def general_forecast_data():
forecast_blue()
red_forecast()

@ -58,7 +58,7 @@ def get_last_red_delta(_last_red):
def get_index_from_db(_index_type):
index_list = db_index_get_index_group(_index_type)
if len(index_list) > 0:
if len(index_list) > 20:
return random.choice(index_list)
else:
return get_random_index_group()

Loading…
Cancel
Save