mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Merge branch 'mail-thread-indicator' into 'master'
Draft: feat: add an indicator about the amount of replies in the aur-requests thread See merge request archlinux/aurweb!707
This commit is contained in:
commit
99a2331ec8
3 changed files with 29 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
import requests
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
from sqlalchemy.orm import backref, relationship
|
from sqlalchemy.orm import backref, relationship
|
||||||
|
|
||||||
|
@ -119,3 +120,19 @@ class PackageRequest(Base):
|
||||||
"""Return the mailing list URL for the request."""
|
"""Return the mailing list URL for the request."""
|
||||||
url = config.get("options", "ml_thread_url") % (self.ml_message_id_hash())
|
url = config.get("options", "ml_thread_url") % (self.ml_message_id_hash())
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def ml_message_api_url(self) -> str:
|
||||||
|
"""Return the mailing list API URL for the request."""
|
||||||
|
url = config.get("options", "ml_thread_api_url") % (self.ml_message_id_hash())
|
||||||
|
return url
|
||||||
|
|
||||||
|
def ml_message_reply_count(self) -> int:
|
||||||
|
"""Return the number of replies in thread"""
|
||||||
|
url = self.ml_message_api_url()
|
||||||
|
count = 0
|
||||||
|
response = requests.get(url, params="?format=json")
|
||||||
|
if response.status_code == 200:
|
||||||
|
response = response.json()
|
||||||
|
for message in response:
|
||||||
|
count += len(message.get("children", []))
|
||||||
|
return count
|
||||||
|
|
|
@ -30,6 +30,7 @@ max_search_results = 2500
|
||||||
max_depends = 1000
|
max_depends = 1000
|
||||||
aur_request_ml = aur-requests@lists.archlinux.org
|
aur_request_ml = aur-requests@lists.archlinux.org
|
||||||
ml_thread_url = https://lists.archlinux.org/archives/list/aur-requests@lists.archlinux.org/thread/%s
|
ml_thread_url = https://lists.archlinux.org/archives/list/aur-requests@lists.archlinux.org/thread/%s
|
||||||
|
ml_thread_api_url = https://lists.archlinux.org/archives/api/list/aur-requests@lists.archlinux.org/thread/%s/emails/
|
||||||
request_idle_time = 1209600
|
request_idle_time = 1209600
|
||||||
request_archive_time = 15552000
|
request_archive_time = 15552000
|
||||||
auto_orphan_age = 15552000
|
auto_orphan_age = 15552000
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
<th>{{ "Type" | tr }}</th>
|
<th>{{ "Type" | tr }}</th>
|
||||||
<th>{{ "Comments" | tr }}</th>
|
<th>{{ "Comments" | tr }}</th>
|
||||||
<th>{{ "Filed by" | tr }}</th>
|
<th>{{ "Filed by" | tr }}</th>
|
||||||
|
<th>{{ "Thread" | tr }}</th>
|
||||||
<th>{{ "Date" | tr }}</th>
|
<th>{{ "Date" | tr }}</th>
|
||||||
<th>{{ "Status" | tr }}</th>
|
<th>{{ "Status" | tr }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -116,6 +117,7 @@
|
||||||
</td>
|
</td>
|
||||||
{# Comments #}
|
{# Comments #}
|
||||||
<td class="wrap">{{ result.Comments }}</td>
|
<td class="wrap">{{ result.Comments }}</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{# Filed by #}
|
{# Filed by #}
|
||||||
{# If the record has an associated User, display a link to that user. #}
|
{# If the record has an associated User, display a link to that user. #}
|
||||||
|
@ -125,10 +127,18 @@
|
||||||
{{ result.User.Username }}
|
{{ result.User.Username }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
{% set reply_count = result.ml_message_reply_count() %}
|
||||||
|
<td>
|
||||||
<a target="_blank" rel="noopener noreferrer" href="{{ result.ml_message_url() }}">
|
<a target="_blank" rel="noopener noreferrer" href="{{ result.ml_message_url() }}">
|
||||||
(PRQ#{{ result.ID }})
|
[PRQ#{{ result.ID }}]
|
||||||
|
{% if reply_count > 0 %}
|
||||||
|
- {{ reply_count }} 📧
|
||||||
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{% set idle_time = config_getint("options", "request_idle_time") %}
|
{% set idle_time = config_getint("options", "request_idle_time") %}
|
||||||
{% set time_delta = (utcnow - result.RequestTS) | int %}
|
{% set time_delta = (utcnow - result.RequestTS) | int %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue