From c8d6872761300a3c115e327f88cc67b9f053aa03 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 11 May 2023 17:03:51 +0300 Subject: [PATCH] rename function --- files/classes/user.py | 7 ++++++- migrations/20230511-add-lifetime-donated-column.sql | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 1ed41084f..50a391438 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -177,7 +177,7 @@ class User(Base): sub_mods = relationship("Mod", primaryjoin="User.id == Mod.user_id", lazy="raise") sub_exiles = relationship("Exile", primaryjoin="User.id == Exile.user_id", lazy="raise") - lifetime_donated = deferred(Column(Integer, server_default=FetchedValue())) + lifetimedonated = deferred(Column(Integer, server_default=FetchedValue())) def __init__(self, **kwargs): @@ -251,6 +251,11 @@ class User(Base): return (succeeded, charged_coins) + @property + @lazy + def lifetime_donated(self): + return self.lifetimedonated or 0 + @property @lazy def num_of_bought_awards(self): diff --git a/migrations/20230511-add-lifetime-donated-column.sql b/migrations/20230511-add-lifetime-donated-column.sql index bd0023497..ab17869b8 100644 --- a/migrations/20230511-add-lifetime-donated-column.sql +++ b/migrations/20230511-add-lifetime-donated-column.sql @@ -1,4 +1,4 @@ -create function public.lifetime_donated(public.users) returns integer +create function public.lifetimedonated(public.users) returns integer language sql immutable strict as $_$ select sum(amount)