def get(self): for chat_id in plan.chats: try: stats = reminderStore.getWeekStats(str(chat_id)) #msg = "Liczone od: 30 stycznia 2017, 17:00 \r\n" msg = "User : number of messages : %\r\n" msg += "----------------------------------" count = 0 for row in stats: count += row[1] for row in stats: percentage = (float(row[1]) / float(count)) * 100.0 msg += "\r\n" + str(row[0]) + " : " + str( row[1]) + " : " + str(round(percentage, 2)) + "%" except: msg = "Statystyki nie sa dostepne" resp = urllib2.urlopen( BASE_URL + 'sendMessage', urllib.urlencode({ 'chat_id': str(chat_id), 'text': msg.encode('utf-8'), 'disable_web_page_preview': 'true', })).read() reminderStore.resetWeekStats()
def __week_stats__(self, chat_id): try: stats = reminderStore.getWeekStats(str(chat_id)) msg = self.__renderStats__(stats, "Liczone od ostatniej niedzieli") except: msg = "Statystyki nie sa dostepne" return msg
def get(self): for chat_id in plan.chats: try: stats = reminderStore.getWeekStats(str(chat_id)) #msg = "Liczone od: 30 stycznia 2017, 17:00 \r\n" msg = "User : number of messages : %\r\n" msg += "----------------------------------" count = 0 for row in stats: count += row[1] for row in stats: percentage = (float(row[1])/float(count))*100.0 msg += "\r\n" + str(row[0]) + " : " + str(row[1]) + " : " + str(round(percentage,2)) + "%" except: msg = "Statystyki nie sa dostepne" resp = urllib2.urlopen(BASE_URL + 'sendMessage', urllib.urlencode({ 'chat_id': str(chat_id), 'text': msg.encode('utf-8'), 'disable_web_page_preview': 'true', })).read() reminderStore.resetWeekStats()