mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
PackageBase: automatically cast Popularity to float
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
3f1ea7d31a
commit
ec38d2f5a0
1 changed files with 9 additions and 0 deletions
|
@ -35,6 +35,9 @@ class PackageBase(Base):
|
|||
"User", backref=backref("package_bases", lazy="dynamic"),
|
||||
foreign_keys=[PackagerUID])
|
||||
|
||||
# A set used to check for floatable values.
|
||||
TO_FLOAT = {"Popularity"}
|
||||
|
||||
def __init__(self, Name: str = None,
|
||||
Flagger: aurweb.models.user.User = None,
|
||||
Maintainer: aurweb.models.user.User = None,
|
||||
|
@ -62,3 +65,9 @@ class PackageBase(Base):
|
|||
datetime.utcnow().timestamp())
|
||||
self.ModifiedTS = kwargs.get("ModifiedTS",
|
||||
datetime.utcnow().timestamp())
|
||||
|
||||
def __getattribute__(self, key: str):
|
||||
attr = super().__getattribute__(key)
|
||||
if key in PackageBase.TO_FLOAT and not isinstance(attr, float):
|
||||
return float(attr)
|
||||
return attr
|
||||
|
|
Loading…
Add table
Reference in a new issue