[PR #6] [CLOSED] Feature: spam score and sorting in quarantine. #1950

Closed
opened 2026-02-27 11:20:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/modoboa/modoboa/pull/6
Author: @lddubeau
Created: 8/10/2013
Status: Closed

Base: masterHead: feature/score-and-sorting-in-quarantine


📝 Commits (6)

  • 5046cf0 If a limit is specified, we have to make sure the value is a string before trying to limit it, otherwise the code fails if the value is not a string (e.g. an integer).
  • 4fb5ace jquery.sortable.js is now needed by quarantine.js
  • 18bcd23 Added everything needed to get the spam score out of the database and be able to sort on it (or any other data presented to the user).
  • 7938a74 Added support for sorting the table that is shown to the user.
  • 66fd8e0 Specify a default order in the default URL.
  • 9d7b0b2 Perform the sorting at the SQL level instead of Python.

📊 Changes

5 files changed (+86 additions, -37 deletions)

View changed files

📝 modoboa/extensions/amavis/sql_listing.py (+46 -33)
📝 modoboa/extensions/amavis/static/amavis/js/quarantine.js (+33 -1)
📝 modoboa/extensions/amavis/templates/amavis/index.html (+1 -0)
📝 modoboa/extensions/amavis/views.py (+1 -1)
📝 modoboa/lib/tables.py (+5 -2)

📄 Description

This patch adds two things:

  1. There is now a "Score" column in the quarantine table showing the spam score that spamassassin assigned to the message.
  2. It is now possible for the user to sort on the various columns of the quarantine table. I've enabled it only for the "Date" and "Score" column but it could presumably be extended to all columns.

Regarding the changes to SQLconnector:

  1. In the old implementation, the unit of measure by which fetch() determined its start and end was different from the unit of measure returned by messages_count(). For normal user, I believe the query used would make it so that the two units would correspond, but for an administrator looking at the entire quarantine it is possible for one item in what was self.messages would have a qm.mail.msgrcpt_set containing more than one item. I believe this would happen if the same spam item was sent to more than one user on the system being managed. (For instance, if the admin has set the default to 40 messages per page and it happens that in one page one message was sent to 10 users, I believe that for that page, the admin would see 9 messages over the 40 message preference.)

    In the new implementation, the number returned by messages_count() is exactly the number of items that fetch() can return.

  2. In the old implementation calling fetch() before messages_count() would have resulted in a crash. That's still true.

  3. Although it would be possible to write a SQL query to get the data out of the database already sorted, I believe this would require bypassing Django's models (either that, or my Django-fu is lacking). I've opted to retrieve the entire data from the database in one shot and do a Python sort. I realize this may be a problem for large datasets.

ETA: This was developed against 1.0.0 because that's what I have installed on my system and I don't see myself upgrading to experimental code just for this modification.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/modoboa/modoboa/pull/6 **Author:** [@lddubeau](https://github.com/lddubeau) **Created:** 8/10/2013 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feature/score-and-sorting-in-quarantine` --- ### 📝 Commits (6) - [`5046cf0`](https://github.com/modoboa/modoboa/commit/5046cf05d4cceb539a30d7302c426d43cd560e8b) If a limit is specified, we have to make sure the value is a string before trying to limit it, otherwise the code fails if the value is not a string (e.g. an integer). - [`4fb5ace`](https://github.com/modoboa/modoboa/commit/4fb5ace8ff06103f85c3651b140ced2f85446423) jquery.sortable.js is now needed by quarantine.js - [`18bcd23`](https://github.com/modoboa/modoboa/commit/18bcd23e0b885432f6b4dd849e2200aae6740397) Added everything needed to get the spam score out of the database and be able to sort on it (or any other data presented to the user). - [`7938a74`](https://github.com/modoboa/modoboa/commit/7938a74abd9f6f021ca9f1a504615d07a50c668d) Added support for sorting the table that is shown to the user. - [`66fd8e0`](https://github.com/modoboa/modoboa/commit/66fd8e057281361e2c40fbdfa25ad6f45d6cbcdd) Specify a default order in the default URL. - [`9d7b0b2`](https://github.com/modoboa/modoboa/commit/9d7b0b24df77dcdce96a244bc3b497c81efac3d2) Perform the sorting at the SQL level instead of Python. ### 📊 Changes **5 files changed** (+86 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `modoboa/extensions/amavis/sql_listing.py` (+46 -33) 📝 `modoboa/extensions/amavis/static/amavis/js/quarantine.js` (+33 -1) 📝 `modoboa/extensions/amavis/templates/amavis/index.html` (+1 -0) 📝 `modoboa/extensions/amavis/views.py` (+1 -1) 📝 `modoboa/lib/tables.py` (+5 -2) </details> ### 📄 Description This patch adds two things: 1. There is now a "Score" column in the quarantine table showing the spam score that spamassassin assigned to the message. 2. It is now possible for the user to sort on the various columns of the quarantine table. I've enabled it only for the "Date" and "Score" column but it could presumably be extended to all columns. Regarding the changes to SQLconnector: 1. In the old implementation, the unit of measure by which `fetch()` determined its start and end was different from the unit of measure returned by `messages_count()`. For normal user, I believe the query used would make it so that the two units would correspond, but for an administrator looking at the entire quarantine it is possible for one item in what was `self.messages` would have a `qm.mail.msgrcpt_set` containing more than one item. I believe this would happen if the same spam item was sent to more than one user on the system being managed. (For instance, if the admin has set the default to 40 messages per page and it happens that in one page one message was sent to 10 users, I believe that for that page, the admin would see 9 messages over the 40 message preference.) In the new implementation, the number returned by `messages_count()` is exactly the number of items that `fetch()` can return. 2. In the old implementation calling `fetch()` before `messages_count()` would have resulted in a crash. That's still true. 3. Although it would be possible to write a SQL query to get the data out of the database already sorted, I believe this would require bypassing Django's models (either that, or my Django-fu is lacking). I've opted to retrieve the entire data from the database in one shot and do a Python sort. I realize this may be a problem for large datasets. ETA: This was developed against 1.0.0 because that's what I have installed on my system and I don't see myself upgrading to experimental code just for this modification. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 11:20:18 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1950
No description provided.