Skip to content
Snippets Groups Projects
Commit 3d2cd70b authored by ale's avatar ale
Browse files

Configurable top N in main view

parent 104d37c7
No related branches found
No related tags found
No related merge requests found
......@@ -15,3 +15,24 @@ users (which are often indicative of an account takeover). Details
(i.e. the message body) for mailing list emails are not saved to the
database to save space and effort.
The tool reads emails from an IMAP account, configured via the
`IMAP_SERVER`, `IMAP_USERNAME` and `IMAP_PASSWORD` parameters (SSL is
assumed). Emails are deleted from the remote account once the reports
have been successfully saved to the database.
The HTTP server can be started with:
```
feedbackloop server --port=1234
```
There are two cron jobs that need to be run periodically:
```
# Fetch new reports.
feedbackloop ingest
# Expire old records.
feedbackloop expire --days=30
```
from flask import render_template, abort
from flask import request, render_template, abort
from sqlalchemy import func, text
from .app import app, db
from .model import FeedbackEntry
......@@ -26,16 +26,17 @@ def by_sender(sender):
@app.route('/')
def index():
n = int(request.args.get('n', '20'))
top_user_senders = db.session.query(
FeedbackEntry.sender,
func.count(FeedbackEntry.id).label('count')).filter(
FeedbackEntry.is_list == False).group_by(
FeedbackEntry.sender).order_by(text('count DESC')).limit(20)
FeedbackEntry.sender).order_by(text('count DESC')).limit(n)
top_list_senders = db.session.query(
FeedbackEntry.sender,
func.count(FeedbackEntry.id).label('count')).filter(
FeedbackEntry.is_list == True).group_by(
FeedbackEntry.sender).order_by(text('count DESC')).limit(20)
FeedbackEntry.sender).order_by(text('count DESC')).limit(n)
top_reporters = db.session.query(
FeedbackEntry.reporter,
func.count(FeedbackEntry.id).label('count')).group_by(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment