ApprovalQueue: use a materialized table #240

Merged
Oleg-Komarov merged 4 commits from approval-queue-fix into main 2024-08-23 15:11:46 +02:00
Showing only changes of commit f7d26d7298 - Show all commits

View File

@ -58,6 +58,16 @@ class ApprovalActivity(CreatedModifiedMixin, RecordDeletionMixin, models.Model):
@property
def queue_sortkey(self):
"""Sorting by moderation status and latest status change timestamp.
The queue is ordered by status: first "awaiting review', then "awaiting changes", then
"approved".
Within each group items with most recent status change are sorted to the top.
Integer timestamp representation takes 4 bytes, the resulting bigint is composed of
0x000000SSTTTTTTTT, where SS byte represents the status change type, and TT bytes represent
timestamp bytes.
"""
timestamp = int(self.date_created.timestamp())
return (self.STATUS_CHANGE_TYPES[self.type] << 32) | timestamp