Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit 979be65

Browse files
committed
Cleaned up mailman daily jobs. Ready to rock on Heroku again.
1 parent b1bc94c commit 979be65

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

getactivity_mailman.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
from lxml import html
55
import requests
6-
from lib import uil
6+
from lib import util
77
from lib.backend import Session
88
from lib.backend.model import ActivityInMailman
99
from datetime import datetime
@@ -13,27 +13,27 @@ def get_activity(verbose=False):
1313
for l in lists:
1414
if verbose: print 'Processing activity for %s...' % l['name']
1515
latest = Session.query(ActivityInMailman)\
16-
.filter(ActivityInMailman.list_name==l['name']
16+
.filter(ActivityInMailman.list_name==l['name'])\
1717
.order_by(ActivityInMailman.message_id.desc())\
1818
.first()
1919
# Walk through message history from the web front-end
2020
archive_url = l['link'].replace('mailman/listinfo','pipermail')
21-
limit = 100
21+
limit = 1000
2222
latest_id = latest.message_id if latest else -1
2323
for msg in _yield_messages(archive_url,latest_id, verbose=verbose):
2424
if verbose: print ' -> got msg #%d (%s: "%s")' % (msg['id'],msg['email'],msg['subject'])
2525
Session.add( ActivityInMailman(
26-
listname = l['name'],
26+
list_name = l['name'],
2727
message_id = msg['id'],
2828
subject = msg['subject'],
2929
author = msg['author'],
3030
email = msg['email'],
3131
link = msg['link'],
3232
timestamp = msg['date'] ) )
3333
limit -= 1
34-
if limit==0:
35-
if verbose: print ' -> Reached activity limit (100)'
36-
break;
34+
#if limit==0:
35+
#if verbose: print ' -> Reached activity limit (100)'
36+
#break;
3737
Session.commit()
3838

3939
def _yield_messages(url, latest_id, verbose=False):

lib/backend/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def toJson(self):
151151

152152
class ActivityInMailman(Base):
153153
__tablename__='activity_mailman'
154-
listname = Column(String, primary_key=True)
154+
list_name = Column(String, primary_key=True)
155155
message_id = Column(Integer, primary_key=True)
156156
subject = Column(String)
157157
author = Column(String)

lib/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from lxml import html
2+
import requests
13

24
def list_mailman_lists(verbose=False):
35
"""Scrape the server for a catalogue of all mailman lists."""

snapshot_mailman.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def snapshot_mailman(verbose=False):
1515
for l in lists:
1616
if verbose: print 'Processing snapshots for %s...' % l['name']
1717
latest = Session.query(SnapshotOfMailman)\
18-
.filter(SnapshotOfMailman.name==l['name'])\
18+
.filter(SnapshotOfMailman.list_name==l['name'])\
1919
.order_by(SnapshotOfMailman.timestamp.desc())\
2020
.first()
2121
# By default, gather 30 days of snapshots
22-
since = today - timedelta(days=30)
22+
since = today - timedelta(days=180)
2323
if latest:
24-
if latest.timestamp>=until:
24+
if latest.timestamp>=today:
2525
if verbose: print ' -> most recent snapshots have already been processed.'
2626
continue
2727
since = latest.timestamp + timedelta(days=1)
@@ -32,7 +32,7 @@ def snapshot_mailman(verbose=False):
3232
while since<today:
3333
posts_today = Session.query(ActivityInMailman)\
3434
.filter(ActivityInMailman.list_name==l['name'])\
35-
.filter(ActivityInMailman.timestamp.between(date,date+day))\
35+
.filter(ActivityInMailman.timestamp.between(since,since+timedelta(days=1)))\
3636
.count()
3737
sn = SnapshotOfMailman(\
3838
list_name=l['name'],\

0 commit comments

Comments
 (0)