forked from yukuku/telebot
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstats.py
65 lines (60 loc) · 2.24 KB
/
stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
import utility
from person import Person
from ride_offer import RideOffer
def getAnagraficaTable():
header = [
"Nome", "Cognome", "Username",
"Id", "Applicazione",
"Enabled", "Modalità Notifica",
"Numero Percorsi Preferiti"
]
result = [header]
more, cursor = True, None
while more:
# not clear if we have to restrict to active RideOffer only
people, cursor, more = Person.query().order(Person.last_name).fetch_page(1000, start_cursor=cursor)
for p in people:
p_details = [
p.getFirstName(), p.getLastName(), p.getUsername(escapeMarkdown=False),
p.chat_id, p.application,
p.enabled, p.getNotificationMode(),
p.percorsi_size
]
p_details = [utility.emptyStringIfNone(x) for x in p_details]
result.append(p_details)
return result
def getOffertePassaggi():
import date_time_util as dtu
header = [
"driver_name_lastname", "driver_username", "driver_id",
"percorso", "registration_datetime",
"active", "start_datetime",
"disactivation_datetime", "time_mode",
"programmato", "programmato_giorni"
]
result = [header]
more, cursor = True, None
while more:
# not clear if we have to restrict to active RideOffer only
offerte, cursor, more = RideOffer.query().fetch_page(1000, start_cursor=cursor)
for o in offerte:
o_details = [
o.getDriverName(), o.driver_username, o.driver_id,
o.getPercorso(), dtu.formatDateTime(o.registration_datetime),
o.active, dtu.formatDateTime(o.start_datetime),
dtu.formatDateTime(o.disactivation_datetime), o.getTimeMode(),
o.programmato, o.getProgrammato_giorni_str()
]
o_details = [utility.emptyStringIfNone(x) for x in o_details]
result.append(o_details)
return result
COMMAND_FUNCTIONS = {
'/anagrafica': getAnagraficaTable,
'/offerte_passaggi': getOffertePassaggi
}
def getStats(inputCommand):
if inputCommand in COMMAND_FUNCTIONS.keys():
return COMMAND_FUNCTIONS[inputCommand]()
else:
return None