Commits

greg elliott committed db89e2c Merge

merge

Comments (0)

Files changed (2)

search/static/css/screen.css

 #apply {
   position:absolute;
   top:0;
-  right:0
+  right:0;
   width:400px;
   border-left:1px solid #999;
   padding-left:100px;

translate/server.py

           (r'/importPerson', ImportPerson),
           (r'/importTranslation', ImportTranslation),
           (r'/importTranslator', ImportTranslator),
-          (r'/log', Log)
+          (r'/log', Log),
+          (r'/stats', Stats)
         ]
         settings = dict(
         login_url=options.root_url + "login",
     logCollection = db.logs
     logCollection.save(log)
 
+class Stats(BaseHandler):
+  @tornado.web.authenticated
+  def get(self):
+    conn = pymongo.Connection(options.mongo_host, options.mongo_port)
+    db = conn.konbit_translate
+    peopleCollection = db.people
+    people = peopleCollection.find().sort("asterisk_id").limit(3000)
+    
+    totalMessages = 0
+    totalMessagesLeft = 0
+    totalPeople = 0
+    totalPeopleLeft = 0
+    totalTimeSpent = 0
+    for person in people:
+      for key, item in person.iteritems():
+        if type(item) is dict:
+          if person[key]['translated'] == False and person[key]['not_translatable'] == False:
+            #logging.error(person[key])
+            totalMessagesLeft += 1
+          if person[key]['not_translatable'] == False: totalMessages += 1
+      if person['completely_translated'] == False:
+        totalPeopleLeft += 1
+      totalPeople += 1
+
+    stats = {"messages: total":totalMessages,"messages: translated":totalMessages-totalMessagesLeft,"people: total":totalPeople,"people: finished":totalPeople-totalPeopleLeft,"average time worked (mins)":((totalMessages-totalMessagesLeft)*12)/60,"percent complete":(totalMessages-totalMessagesLeft)/float(totalMessages)*100}
+
+    self.write(json_encode(stats))
+            
+    
+    
+
+
 
 # ===================================================================
 # = Standard Tornado server stuff, switch port to 80 for production =