Skip to content

Commit fe6a59e

Browse files
Fix db side stats calculation (#721)
1 parent 89572eb commit fe6a59e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

admin_panel/bd_models/models.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,22 @@ def get_queryset(self) -> models.QuerySet[Special]:
213213
class BaseBallInstanceManager[T: models.Model](Manager[T]):
214214
def with_stats(self):
215215
return self.annotate(
216-
attack=Cast(F("attack_bonus"), models.BigIntegerField()) * F("ball__attack"),
217-
health=Cast(F("health_bonus"), models.BigIntegerField()) * F("ball__health"),
216+
attack=Cast(
217+
models.ExpressionWrapper(
218+
F("ball__attack")
219+
* (models.Value(1.0) + Cast(F("attack_bonus"), models.FloatField()) / models.Value(100.0)),
220+
output_field=models.FloatField(),
221+
),
222+
models.BigIntegerField(),
223+
),
224+
health=Cast(
225+
models.ExpressionWrapper(
226+
F("ball__health")
227+
* (models.Value(1.0) + Cast(F("health_bonus"), models.FloatField()) / models.Value(100.0)),
228+
output_field=models.FloatField(),
229+
),
230+
models.BigIntegerField(),
231+
),
218232
)
219233

220234

0 commit comments

Comments
 (0)