Permalink
Browse files

Updated agenda and stats scripts, with a couple model fixes along the…

… way.
  • Loading branch information...
1 parent f2b3fc4 commit 6e1f38d67a5328a4b3b0642e48e8a497c5762a43 @jacobian jacobian committed Aug 27, 2012
Showing with 57 additions and 36 deletions.
  1. +21 −8 pycon_bot/models.py
  2. +1 −1 pycon_bot/mongo.py
  3. +19 −18 scripts/agenda.py
  4. +16 −9 scripts/stats.py
View
@@ -5,23 +5,33 @@ class SiteVotes(mongoengine.EmbeddedDocument):
Votes on a talk on the site. Duplicated here for reporting purposes, should
be considered read-only for the bots.
"""
- plus_1 = mongoengine.IntField(min_value=0)
- plus_0 = mongoengine.IntField(min_value=0)
- minus_0 = mongoengine.IntField(min_value=0)
- minus_1 = mongoengine.IntField(min_value=0)
+ plus_1 = mongoengine.IntField(min_value=0, default=0)
+ plus_0 = mongoengine.IntField(min_value=0, default=0)
+ minus_0 = mongoengine.IntField(min_value=0, default=0)
+ minus_1 = mongoengine.IntField(min_value=0, default=0)
+
+ def __unicode__(self):
+ return u"%s/%s/%s/%s" % (self.plus_1, self.plus_0, self.minus_0, self.minus_1)
+
+ @property
+ def total(self):
+ return self.plus_1 + self.plus_0 + self.minus_0 + self.minus_1
class KittendomeVotes(mongoengine.EmbeddedDocument):
"""
Records the votes on a talk in a Kittendome session.
"""
- yay = mongoengine.IntField(min_value=0)
- nay = mongoengine.IntField(min_value=0)
- abstain = mongoengine.IntField(min_value=0)
+ yay = mongoengine.IntField(min_value=0, default=0)
+ nay = mongoengine.IntField(min_value=0, default=0)
+ abstain = mongoengine.IntField(min_value=0, default=0)
+
+ def __unicode__(self):
+ return u"%s/%s/ %s" (self.yay, self.nay, self.abstain)
class TalkProposal(mongoengine.Document):
STATUSES = [
('unreviewed', 'Unreviewed'),
- ('pre-rejected', 'Rejected at pre-season Kittendome'),
+ ('hold', 'On hold'),
('rejected', 'Rejected'),
('thunderdome', 'Accepted into Thunderdome'),
('accepted', 'Accepted'),
@@ -36,3 +46,6 @@ class TalkProposal(mongoengine.Document):
site_votes = mongoengine.EmbeddedDocumentField(SiteVotes)
kittendome_votes = mongoengine.EmbeddedDocumentField(KittendomeVotes)
debate_transcript = mongoengine.StringField()
+
+ def __unicode__(self):
+ return u"#%s: %s" % (self.talk_id, self.title)
View
@@ -2,7 +2,7 @@
import urlparse
import mongoengine
-def connect(dsn):
+def connect(dsn=None):
"""
Connect to mongo from a given dsn flag or by reading env.
"""
View
@@ -1,26 +1,27 @@
"""
-Generate an agenda for the next meeting::
-
- python agenda.py talks.json [number]
+Generate an agenda for the next meeting.
Skips over any talks already reviewed, then prints out a simple agenda of the
next [number] talks.
-
"""
-import sys
-import json
-with open(sys.argv[1]) as fp:
- talks = json.load(fp)
-
-try:
- num_talks = int(sys.argv[2])
-except (IndexError, ValueError):
- num_talks = 12
+import sys
+import argparse
+import pycon_bot.mongo
+from pycon_bot.models import TalkProposal
-index = 0
-while "decision" in talks[index]:
- index += 1
+p = argparse.ArgumentParser()
+p.add_argument('--dsn')
+p.add_argument('-n', '--num', type=int, default=12)
+args = p.parse_args()
+if not pycon_bot.mongo.connect(args.dsn):
+ sys.stderr.write("Need to pass --dsn or set env[MONGO_DSN].")
+ sys.exit(1)
-for talk in talks[index:index+num_talks]:
- print u'http://us.pycon.org/2012/review/{id} - {name}'.format(**talk)
+nr = args.num
+for p in TalkProposal.objects(status='unreviewed'):
+ if p.site_votes.total >= 3:
+ print u'http://us.pycon.org/2013/reviews/review/%s - %s' % (p.talk_id, p.title)
+ nr -= 1
+ if nr == 0:
+ break
View
@@ -3,19 +3,26 @@
"""
import sys
-import json
+import argparse
+import pycon_bot.mongo
+from pycon_bot.models import TalkProposal
-with open(sys.argv[1]) as fp:
- talks = json.load(fp)
+p = argparse.ArgumentParser()
+p.add_argument('--dsn')
+args = p.parse_args()
+if not pycon_bot.mongo.connect(args.dsn):
+ sys.stderr.write("Need to pass --dsn or set env[MONGO_DSN].")
+ sys.exit(1)
-total = len(talks)
-reviewed = len([t for t in talks if 'decision' in t])
+
+total = len(TalkProposal.objects)
+reviewed = len(TalkProposal.objects(status__ne='unreviewed'))
remaining = total - reviewed
percent_reviewed = float(reviewed) / total
-accepted = len([t for t in talks if t.get('decision') == 'accepted'])
-percent_accepted = float(accepted) / reviewed
-rejected = len([t for t in talks if t.get('decision') in ('rejected', 'poster')])
-percent_rejected = float(rejected) / reviewed
+accepted = len(TalkProposal.objects(status='thunderdome'))
+percent_accepted = float(accepted) / reviewed if reviewed else 0
+rejected = len(TalkProposal.objects(status='rejected'))
+percent_rejected = float(rejected) / reviewed if reviewed else 0
print """{reviewed}/{total} talks reviewed ({percent_reviewed:.0%}); {remaining} talks remaining.
{accepted} talks accepted ({percent_accepted:.0%}); {rejected} talks rejected ({percent_rejected:.0%}).""".format(**locals())

0 comments on commit 6e1f38d

Please sign in to comment.