Browse Source

count tool

Davide Alberani 7 years ago
parent
commit
f834f7afe0
2 changed files with 42 additions and 0 deletions
  1. 5 0
      tools/README.md
  2. 37 0
      tools/count.py

+ 5 - 0
tools/README.md

@@ -10,3 +10,8 @@ Besides some standard packages, it also requires the following:
 
     sudo pip3 install serial
     sudo pip3 install requests
+
+count
+=====
+
+Just print some stats about an event.

+ 37 - 0
tools/count.py

@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import sys
+import monco
+
+def info(event):
+    tickets = event['tickets']
+    total = 0
+    attended = 0
+    afternoon = 0
+    for ticket in tickets:
+        if ticket.get('cancelled'):
+            continue
+        email = ticket.get('email')
+        if ticket.get('attended'):
+            attended += 1
+        if ticket.get('afternoon_attended'):
+            afternoon += 1
+        total += 1
+    title = event['title']
+    print('Total registered: %d' % total)
+    print('Attendees: %d' % attended)
+    print('Afternoon: %d' % afternoon)
+    print('')
+
+
+def run():
+    try:
+        db = monco.Monco(dbName='eventman')
+        events = db.query('events', {'title': sys.argv[1]})
+        info(events[0])
+    except:
+        print('count.py "title of event"')
+        sys.exit(1)
+
+if __name__ == '__main__':
+    run()