优化SQL及UI
This commit is contained in:
parent
89daced3ad
commit
e75f8fc4bb
|
@ -19,9 +19,9 @@ class Model(BaseModel):
|
|||
|
||||
class Battle(BaseModel):
|
||||
id = PrimaryKeyField()
|
||||
challenger_path = CharField(null = False)
|
||||
challenger_path = CharField(null = False, index = True)
|
||||
challenger_position = CharField(null = False)
|
||||
status = IntegerField(null = False)
|
||||
status = IntegerField(null = False, index = True)
|
||||
challenger_wp = DecimalField(null=True)
|
||||
challenger_adp = DecimalField(null=True)
|
||||
class Meta:
|
||||
|
@ -34,7 +34,7 @@ class Baseline(BaseModel):
|
|||
landlord_up_path = ForeignKeyField(Model, to_field='path',related_name = "model")
|
||||
landlord_front_path = ForeignKeyField(Model, to_field='path',related_name = "model")
|
||||
landlord_down_path = ForeignKeyField(Model, to_field='path',related_name = "model")
|
||||
rank = IntegerField(null = False)
|
||||
rank = IntegerField(null = False, index = True)
|
||||
landlord_wp = DecimalField(null=False)
|
||||
farmer_wp = DecimalField(null=False)
|
||||
landlord_adp = DecimalField(null=False)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import itertools
|
||||
import os
|
||||
|
||||
from peewee import JOIN
|
||||
|
||||
from douzero.server.orm import Model, Battle, Baseline
|
||||
from douzero.server.battle import tick
|
||||
|
@ -83,6 +86,10 @@ def metrics():
|
|||
baseline = baselines[i]
|
||||
baseline_metric = {
|
||||
'baseline': {
|
||||
'landlord_path': os.path.basename(str(baseline.landlord_path)).split('.')[0],
|
||||
'landlord_up_path': os.path.basename(str(baseline.landlord_up_path)).split('.')[0].replace('landlord_', ''),
|
||||
'landlord_down_path': os.path.basename(str(baseline.landlord_down_path)).split('.')[0].replace('landlord_', ''),
|
||||
'landlord_front_path': os.path.basename(str(baseline.landlord_front_path)).split('.')[0].replace('landlord_', ''),
|
||||
'landlord_wp': '%.4f' % float(baseline.landlord_wp),
|
||||
'landlord_adp': '%.4f' % float(baseline.landlord_adp),
|
||||
'farmer_wp': '%.4f' % float(baseline.farmer_wp),
|
||||
|
@ -94,16 +101,25 @@ def metrics():
|
|||
'landlord_front': {},
|
||||
'landlord_down': {}
|
||||
}
|
||||
models = Model.select(Model.frame, Model.path).where(
|
||||
results = (
|
||||
Model
|
||||
.select(Model.frame, Model.path, Battle.challenger_position, Battle.challenger_wp, Battle.challenger_adp)
|
||||
.where(
|
||||
Model.type == type,
|
||||
Model.create_time >= baseline.create_time,
|
||||
Model.create_time <= end_time
|
||||
).order_by(Model.create_time.asc())
|
||||
)
|
||||
.join(Battle, JOIN.INNER, on=(
|
||||
(Battle.challenger_path == Model.path) &
|
||||
(Battle.status > 0) &
|
||||
(Battle.status != 3))
|
||||
)
|
||||
.order_by(Model.create_time.asc())
|
||||
)
|
||||
end_time = baseline.create_time
|
||||
for model in models:
|
||||
battle = Battle.get_or_none(Battle.challenger_path == model.path, Battle.status > 0, Battle.status != 3)
|
||||
if battle is not None:
|
||||
baseline_metric[str(battle.challenger_position)][model.frame] = {
|
||||
for result in results:
|
||||
battle = result.battle
|
||||
baseline_metric[str(battle.challenger_position)][result.frame] = {
|
||||
'wp': '%.4f' % float(battle.challenger_wp),
|
||||
'adp': '%.4f' % float(battle.challenger_adp)
|
||||
}
|
||||
|
|
|
@ -22,10 +22,14 @@
|
|||
}
|
||||
var json = {
|
||||
title: {
|
||||
text: rank
|
||||
text: 'Baseline: ' + rank
|
||||
},
|
||||
subtitle: {
|
||||
text: ''
|
||||
text: 'WP: ' + result[rank]['baseline'].landlord_wp + '\t/\t' + result[rank]['baseline'].farmer_wp + '<br/>' +
|
||||
result[rank]['baseline'].landlord_path + '\t/\t' +
|
||||
result[rank]['baseline'].landlord_down_path + '\t/\t' +
|
||||
result[rank]['baseline'].landlord_front_path + '\t/\t' +
|
||||
result[rank]['baseline'].landlord_up_path
|
||||
},
|
||||
}
|
||||
categories = new Set()
|
||||
|
|
Loading…
Reference in New Issue