From 043b4132856736a4654a4572c9f201414d771b71 Mon Sep 17 00:00:00 2001 From: Lei Shi Date: Tue, 5 Dec 2023 03:15:39 +0100 Subject: [PATCH] :bug: Fix standard deviation is not showing correctly in dps line chart * Fix standard deviation is not showing correctly in dps line chart * remove console.log * simpler math --- plugins/genshin/gcsim/renderer.py | 33 +---- plugins/genshin/gcsim/runner.py | 6 +- resources/genshin/gcsim/result.jinja2 | 186 +++++++++++++++++--------- 3 files changed, 134 insertions(+), 91 deletions(-) diff --git a/plugins/genshin/gcsim/renderer.py b/plugins/genshin/gcsim/renderer.py index faebe119..5d105e1c 100644 --- a/plugins/genshin/gcsim/renderer.py +++ b/plugins/genshin/gcsim/renderer.py @@ -64,33 +64,12 @@ class GCSimResultRenderer: ] result["extra"]["damage"] = { "xAxis": [i * 0.5 for i in range(len(result["statistics"]["damage_buckets"]["buckets"]))], - "series": [ - { - "data": [bucket["mean"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], - "type": "line", - "stack": "x", - "areaStyle": {}, - "name": "平均伤害", - }, - { - "data": [bucket["min"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], - "type": "line", - "stack": "x", - "name": "最小伤害", - }, - { - "data": [bucket["max"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], - "type": "line", - "stack": "x", - "name": "最大伤害", - }, - { - "data": [bucket["sd"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], - "type": "line", - "stack": "x", - "name": "标准差", - }, - ], + "data": { + "mean": [bucket["mean"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], + "min": [bucket["min"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], + "max": [bucket["max"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], + "sd": [bucket["sd"] for bucket in result["statistics"]["damage_buckets"]["buckets"]], + }, } return result diff --git a/plugins/genshin/gcsim/runner.py b/plugins/genshin/gcsim/runner.py index 82855e26..c2f3f1db 100644 --- a/plugins/genshin/gcsim/runner.py +++ b/plugins/genshin/gcsim/runner.py @@ -10,6 +10,7 @@ from typing import Optional, Dict, List, Union, TYPE_CHECKING, Tuple, Coroutine, import gcsim_pypi from pydantic import BaseModel +from gram_core.config import config from metadata.shortname import idToName from modules.apihelper.client.components.remote import Remote from modules.gcsim.cache import GCSimCache @@ -171,8 +172,9 @@ class GCSimRunner: merged_script = GCSimConverter.merge_character_infos(script, character_infos) except ValueError: return GCSimResult(error="无法合并角色信息", user_id=user_id, uid=uid, script_key=script_key) - if file_id := await self.cache.get_cache(uid, hash(str(merged_script))): - return GCSimResult(error=None, user_id=user_id, uid=uid, script_key=script_key, file_id=file_id) + if not config.debug: + if file_id := await self.cache.get_cache(uid, hash(str(merged_script))): + return GCSimResult(error=None, user_id=user_id, uid=uid, script_key=script_key, file_id=file_id) await self.player_gcsim_scripts.write_script(uid, script_key, str(merged_script)) limit = _get_limit_command() command = [ diff --git a/resources/genshin/gcsim/result.jinja2 b/resources/genshin/gcsim/result.jinja2 index 65c7dc5c..f2d71fef 100644 --- a/resources/genshin/gcsim/result.jinja2 +++ b/resources/genshin/gcsim/result.jinja2 @@ -1,101 +1,163 @@ + - + Title - + + -
- -
- - {% include "genshin/gcsim/characters.jinja2" %} - - - {% include "genshin/gcsim/summary.jinja2" %} - -
- - -
-
+
+ +
+ + {% include "genshin/gcsim/characters.jinja2" %} + + + {% include "genshin/gcsim/summary.jinja2" %} +
-
+ + +
+
+
+
+
- -
- - -
- {% include "genshin/gcsim/other_summary.jinja2" %} - -
- - -
+ + +
+ {% include "genshin/gcsim/other_summary.jinja2" %} +
+ + +
+
+
- -
+ \ No newline at end of file