From 10ddcbea3732b1c066458aea533480f2bb399ef5 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Tue, 15 May 2018 20:17:53 +0100 Subject: Add snowflake index on oauth_data and use it for deletions We were using id previously, but that was no longer the correct key --- pysite/migrations/tables/oauth_data/__init__.py | 0 pysite/migrations/tables/oauth_data/v1.py | 3 +++ pysite/views/api/bot/user.py | 4 ++-- templates/main/navigation.html | 16 +++++++++++----- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 pysite/migrations/tables/oauth_data/__init__.py create mode 100644 pysite/migrations/tables/oauth_data/v1.py diff --git a/pysite/migrations/tables/oauth_data/__init__.py b/pysite/migrations/tables/oauth_data/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pysite/migrations/tables/oauth_data/v1.py b/pysite/migrations/tables/oauth_data/v1.py new file mode 100644 index 00000000..8448d8e5 --- /dev/null +++ b/pysite/migrations/tables/oauth_data/v1.py @@ -0,0 +1,3 @@ +def run(db, table, table_obj): + db.run(db.query(table).index_create("snowflake")) + db.run(db.query(table).index_wait("snowflake")) diff --git a/pysite/views/api/bot/user.py b/pysite/views/api/bot/user.py index 077991f5..58963682 100644 --- a/pysite/views/api/bot/user.py +++ b/pysite/views/api/bot/user.py @@ -52,7 +52,7 @@ class UserView(APIView, DBMixin): all_oauth_data = self.db.run(self.db.query(self.oauth_table_name), coerce=list) for item in all_oauth_data: - if item["id"] not in user_ids: + if item["snowflake"] not in user_ids: self.db.delete(self.oauth_table_name, item["id"], durability="soft") oauth_deletions += 1 @@ -94,7 +94,7 @@ class UserView(APIView, DBMixin): oauth_deletions = self.db.run( self.db.query(self.oauth_table_name) - .get_all(*user_ids) + .get_all(*user_ids, index="snowflake") .delete() ).get("deleted", 0) diff --git a/templates/main/navigation.html b/templates/main/navigation.html index a615468e..8333fd18 100644 --- a/templates/main/navigation.html +++ b/templates/main/navigation.html @@ -48,19 +48,19 @@
  • Information
  • {% endif %} - {% if current_page == "info/jams" %} + {% if current_page == "info.jams" %}
  • Code Jams
  • {% else %}
  • Code Jams
  • {% endif %} - {% if current_page == "info/help" %} + {% if current_page == "info.help" %}
  • Getting Help
  • {% else %}
  • Getting Help
  • {% endif %} - {% if current_page == "info/resources" %} + {% if current_page == "info.resources" %}
  • Resources
  • {% else %}
  • Resources
  • @@ -72,19 +72,25 @@
  • About
  • {% endif %} - {% if current_page == "about/partners" %} + {% if current_page == "about.partners" %}
  • Partners
  • {% else %}
  • Partners
  • {% endif %} - {% if current_page == "about/rules" %} + {% if current_page == "about.rules" %}
  • Server Rules
  • {% else %}
  • Server Rules
  • {% endif %}
  • + + {% if current_page.startswith("about.privacy") %} +
  • Privacy
  • + {% else %} +
  • Privacy
  • + {% endif %} -- cgit v1.2.3