300e5f4 by Arvind at 2014-01-09 |
1 |
import argparse |
|
2 |
import datetime |
|
3 |
import query |
|
4 |
|
|
5 |
parser = argparse.ArgumentParser(description='Generate report for the date specified.') |
|
6 |
parser.add_argument('-s','--start-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="Start date (YYYY-MM-DD)") |
|
7 |
parser.add_argument('-e','--end-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="End date (YYYY-MM-DD)") |
|
8 |
parser.add_argument('-S','--start-time', type=str, default = '00:00:00', help="Start time (HH:MM:SS)") |
|
9 |
parser.add_argument('-E','--end-time', type=str, default='23:59:59', help="Start time (HH:MM:SS)") |
9d54d1e by Arvind at 2014-01-09 |
10 |
|
|
11 |
|
300e5f4 by Arvind at 2014-01-09 |
12 |
args = parser.parse_args() |
|
13 |
startDate = args.start_date + " " + args.start_time |
|
14 |
endDate = args.end_date + " " + args.end_time |
|
15 |
|
|
16 |
|
|
17 |
postings = query.Query('lb_postings') |
|
18 |
print '{0}: {1}'.format("Number of postings published", postings.posts(startDate, endDate)) |
|
19 |
print '{0}: {1}'.format("Number of recordings made", postings.recordings(startDate, endDate)) |
|
20 |
print '{0}: {1}'.format("Number of impact stories", postings.filter_by_title('impact', startDate, endDate)) |
|
21 |
|
|
22 |
callDetails = query.Query('cdr') |
|
23 |
average_call_length = callDetails.average(startDate, endDate) |
|
24 |
audio_minutes = callDetails.sum(startDate, endDate) |
|
25 |
channel1_minutes = callDetails.load('SIP/10.0.0.20', startDate, endDate) |
|
26 |
channel2_minutes = callDetails.load('SIP/10.0.0.21', startDate, endDate) |
|
27 |
channel3_minutes = callDetails.load('SIP/10.0.0.22', startDate, endDate) |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
print '{0}: {1}'.format("Number of missed calls", callDetails.missedCalls(startDate, endDate)) |
9d54d1e by Arvind at 2014-01-09 |
32 |
print '{0}: {1}'.format("Number of missed calls on 'mobilink'", callDetails.missedCalls(startDate, endDate, 'mobilink')) |
|
33 |
print '{0}: {1}'.format("Number of missed calls on 'mobilinktata'", callDetails.missedCalls(startDate, endDate, 'mobilinktata')) |
300e5f4 by Arvind at 2014-01-09 |
34 |
print '{0}: {1}'.format("Number of calls answered", callDetails.answeredCalls(startDate, endDate)) |
9d54d1e by Arvind at 2014-01-09 |
35 |
print '{0}: {1}'.format("Number of calls lasting less than 30 seconds", callDetails.filter_calls_by_duration(startDate, endDate, 30)) |
|
36 |
print '{0}: {1:.4f}'.format("Average length of calls", average_call_length) |
|
37 |
print '{0}: {1:.4f}'.format("Total number of audio minutes played", audio_minutes) |
|
38 |
print '{0}: {1:.4f}'.format("Audio minutes on channel 10.0.0.20", channel1_minutes) |
|
39 |
print '{0}: {1:.4f}'.format("Audio minutes on channel 10.0.0.21", channel2_minutes) |
|
40 |
print '{0}: {1:.4f}'.format("Audio minutes on channel 10.0.0.22", channel3_minutes) |
|
41 |
print '{0}: {1:.4f}'.format("Load on channel 10.0.0.20", channel1_minutes/audio_minutes) |
|
42 |
print '{0}: {1:.4f}'.format("Load on channel 10.0.0.21", channel2_minutes/audio_minutes) |
|
43 |
print '{0}: {1:.4f}'.format("Load on channel 10.0.0.22", channel3_minutes/audio_minutes) |