diff options
| author | 2022-02-19 17:59:26 +0000 | |
|---|---|---|
| committer | 2022-03-16 21:52:06 +0000 | |
| commit | 0aed5f7913e7ce268ddb56127f84a5386ede5739 (patch) | |
| tree | 080039ca0d001c67e01a5cb5b33f3700a7479b5f /pydis_site/apps/api/models | |
| parent | Move FilterList imports down so they're sorted (diff) | |
Add support for BumpedThreads to be stored in site
Following our move to use Redis as just a cache, this PR allows the site to store a list of threads that need to be bumped.
The bot will interact with this within the ThreadBumper cog.
Diffstat (limited to 'pydis_site/apps/api/models')
| -rw-r--r-- | pydis_site/apps/api/models/__init__.py | 1 | ||||
| -rw-r--r-- | pydis_site/apps/api/models/bot/__init__.py | 1 | ||||
| -rw-r--r-- | pydis_site/apps/api/models/bot/bumped_thread.py | 22 |
3 files changed, 24 insertions, 0 deletions
diff --git a/pydis_site/apps/api/models/__init__.py b/pydis_site/apps/api/models/__init__.py index e83473c9..a197e988 100644 --- a/pydis_site/apps/api/models/__init__.py +++ b/pydis_site/apps/api/models/__init__.py @@ -1,6 +1,7 @@ # flake8: noqa from .bot import ( BotSetting, + BumpedThread, DocumentationLink, DeletedMessage, FilterList, diff --git a/pydis_site/apps/api/models/bot/__init__.py b/pydis_site/apps/api/models/bot/__init__.py index 64676fdb..013bb85e 100644 --- a/pydis_site/apps/api/models/bot/__init__.py +++ b/pydis_site/apps/api/models/bot/__init__.py @@ -1,5 +1,6 @@ # flake8: noqa from .bot_setting import BotSetting +from .bumped_thread import BumpedThread from .deleted_message import DeletedMessage from .documentation_link import DocumentationLink from .filter_list import FilterList diff --git a/pydis_site/apps/api/models/bot/bumped_thread.py b/pydis_site/apps/api/models/bot/bumped_thread.py new file mode 100644 index 00000000..cdf9a950 --- /dev/null +++ b/pydis_site/apps/api/models/bot/bumped_thread.py @@ -0,0 +1,22 @@ +from django.core.validators import MinValueValidator +from django.db import models + +from pydis_site.apps.api.models.mixins import ModelReprMixin + + +class BumpedThread(ModelReprMixin, models.Model): + """A list of thread IDs to be bumped.""" + + thread_id = models.BigIntegerField( + primary_key=True, + help_text=( + "The thread ID that should be bumped." + ), + validators=( + MinValueValidator( + limit_value=0, + message="Thread IDs cannot be negative." + ), + ), + verbose_name="Thread ID", + ) |