diff options
author | 2019-09-17 16:24:10 +0200 | |
---|---|---|
committer | 2019-09-17 16:24:10 +0200 | |
commit | 0576b70f921e7bdf9d950ecb8c4202200a61d5f9 (patch) | |
tree | 8066b1c5076e0a0b7b9b3288b99c9be95c168a3c /pydis_site/apps/api/models/bot | |
parent | Add test cases for `TypeError` fallbacks. (diff) |
Make API return infraction list with newest first
The most recent infraction a user has is usually the most relevant to
us. This PR aims to make our life easier by sorting the infractions by
their `inserted_at` date, with the most recent insertion date first.
Note: The `id` is not entirely in chronological order, because we did
not import historical infractions in chronological order. That's why
the `inserted_at` field is specified instead of the `id` field.
Diffstat (limited to 'pydis_site/apps/api/models/bot')
-rw-r--r-- | pydis_site/apps/api/models/bot/infraction.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pydis_site/apps/api/models/bot/infraction.py b/pydis_site/apps/api/models/bot/infraction.py index da91d6c2..dfb32a97 100644 --- a/pydis_site/apps/api/models/bot/infraction.py +++ b/pydis_site/apps/api/models/bot/infraction.py @@ -66,3 +66,8 @@ class Infraction(ModelReprMixin, models.Model): if self.hidden: s += " (hidden)" return s + + class Meta: + """Defines the meta options for the infraction model.""" + + ordering = ['-inserted_at'] |