From e36adb5bf42ef8132dadef9f9ed3867007dce340 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 26 Jun 2022 07:11:25 +0200 Subject: [PATCH] reduce query volume, badge edition --- files/classes/user.py | 4 +++- files/routes/posts.py | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 5f8cc96df..a8ddc4337 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -233,8 +233,10 @@ class User(Base): elif self.patron == 7: discount = 0.60 else: discount = 1 + owned_badges = [x.badge_id for x in self.badges] + for badge in discounts: - if self.has_badge(badge): discount -= discounts[badge] + if badge in owned_badges: discount -= discounts[badge] return discount diff --git a/files/routes/posts.py b/files/routes/posts.py index 0daf8c01f..b3ccaae11 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -30,14 +30,6 @@ if path.exists(f'snappy_{SITE_NAME}.txt'): with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f: snappyquotes += f.read().split("\n{[para]}\n") -discounts = { - 69: 0.02, - 70: 0.04, - 71: 0.06, - 72: 0.08, - 73: 0.10, -} - titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}