重构查询逻辑,新增字段
This commit is contained in:
parent
c970a59655
commit
934a186987
|
@ -28,7 +28,7 @@ class Battle(BaseModel):
|
||||||
id = PrimaryKeyField()
|
id = PrimaryKeyField()
|
||||||
challenger_path = CharField(null = False, max_length=255, index = True)
|
challenger_path = CharField(null = False, max_length=255, index = True)
|
||||||
challenger_position = CharField(null = False, max_length=32)
|
challenger_position = CharField(null = False, max_length=32)
|
||||||
opponent_rank = IntegerField(null = False)
|
opponent_rank = IntegerField(null = False, index = True)
|
||||||
status = IntegerField(null = False, index = True)
|
status = IntegerField(null = False, index = True)
|
||||||
challenger_wp = DecimalField(null=True)
|
challenger_wp = DecimalField(null=True)
|
||||||
challenger_adp = DecimalField(null=True)
|
challenger_adp = DecimalField(null=True)
|
||||||
|
|
|
@ -63,7 +63,6 @@ def charts():
|
||||||
def metrics():
|
def metrics():
|
||||||
type = request.args.get('type')
|
type = request.args.get('type')
|
||||||
baselines = Baseline.select().order_by(Baseline.rank.desc()).limit(3)
|
baselines = Baseline.select().order_by(Baseline.rank.desc()).limit(3)
|
||||||
end_time = datetime.now()
|
|
||||||
metrics = {}
|
metrics = {}
|
||||||
for i in range(len(baselines)):
|
for i in range(len(baselines)):
|
||||||
baseline = baselines[i]
|
baseline = baselines[i]
|
||||||
|
@ -89,8 +88,7 @@ def metrics():
|
||||||
.select(Model.frame, Model.path, Battle.challenger_position, Battle.challenger_wp, Battle.challenger_adp)
|
.select(Model.frame, Model.path, Battle.challenger_position, Battle.challenger_wp, Battle.challenger_adp)
|
||||||
.where(
|
.where(
|
||||||
Model.type == type,
|
Model.type == type,
|
||||||
Model.create_time >= baseline.create_time,
|
Battle.opponent_rank == baseline.rank
|
||||||
Model.create_time <= end_time
|
|
||||||
)
|
)
|
||||||
.join(Battle, JOIN.INNER, on=(
|
.join(Battle, JOIN.INNER, on=(
|
||||||
(Battle.challenger_path == Model.path) &
|
(Battle.challenger_path == Model.path) &
|
||||||
|
@ -98,7 +96,6 @@ def metrics():
|
||||||
)
|
)
|
||||||
.order_by(Model.create_time.asc())
|
.order_by(Model.create_time.asc())
|
||||||
)
|
)
|
||||||
end_time = baseline.create_time
|
|
||||||
for result in results:
|
for result in results:
|
||||||
battle = result.battle
|
battle = result.battle
|
||||||
baseline_metric[str(battle.challenger_position)][result.frame] = {
|
baseline_metric[str(battle.challenger_position)][result.frame] = {
|
||||||
|
|
Loading…
Reference in New Issue