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