Commit 9d54d1e44c93e7859f9b267221931dc6b2865aae
- Diff rendering mode:
- inline
- side by side
query.py
(8 / 2)
  | |||
40 | 40 | sum = res.sum/60 | |
41 | 41 | return sum | |
42 | 42 | ||
43 | def missedCalls(self, date, dateRange): | ||
44 | return self.t.lt.query.filter(((self.t.lt.dcontext == 'mobilink') | | ||
43 | def missedCalls(self, date, dateRange, modem=None): | ||
44 | if modem is None: | ||
45 | return self.t.lt.query.filter(((self.t.lt.dcontext == 'mobilink') | | ||
45 | 46 | (self.t.lt.dcontext == 'mobilinktata')) & | |
46 | 47 | (self.t.lt.calldate.between(date, dateRange))).count() | |
48 | else: | ||
49 | return self.t.lt.query.filter(self.t.lt.dcontext == modem, self.t.lt.calldate.between(date, dateRange)).count() | ||
47 | 50 | ||
48 | 51 | def answeredCalls(self, date, dateRange): | |
49 | 52 | return self.t.lt.query.filter(self.t.lt.dcontext == 'callback', | |
50 | 53 | self.t.lt.calldate.between(date, dateRange)).count() | |
54 | |||
55 | def filter_calls_by_duration(self, date, dateRange, duration): | ||
56 | return self.t.lt.query.filter(self.t.lt.dcontext == 'callback', self.t.lt.duration < duration, self.t.lt.calldate.between(date, dateRange)).count() |
report.py
(13 / 32)
  | |||
7 | 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 | 8 | parser.add_argument('-S','--start-time', type=str, default = '00:00:00', help="Start time (HH:MM:SS)") | |
9 | 9 | parser.add_argument('-E','--end-time', type=str, default='23:59:59', help="Start time (HH:MM:SS)") | |
10 | |||
11 | |||
10 | 12 | args = parser.parse_args() | |
11 | 13 | startDate = args.start_date + " " + args.start_time | |
12 | 14 | endDate = args.end_date + " " + args.end_time | |
… | … | ||
27 | 27 | channel3_minutes = callDetails.load('SIP/10.0.0.22', startDate, endDate) | |
28 | 28 | ||
29 | 29 | ||
30 | # avg_query = callDetails.lt.query.with_entities(func.avg(callDetails.lt.duration).label('average'), | ||
31 | # func.sum(callDetails.lt.duration).label('sum')).filter(callDetails.lt.dcontext == "callback", callDetails.lt.calldate.between(date, dateRange)) | ||
32 | # sumCh1_query = callDetails.lt.query.with_entities(func.sum(callDetails.lt.duration).label('sumCh1')).filter(callDetails.lt.dcontext == "callback", callDetails.lt.channel.like('SIP/10.0.0.20%'), callDetails.lt.calldate.between(date, dateRange)) | ||
33 | # sumCh2_query = callDetails.lt.query.with_entities(func.sum(callDetails.lt.duration).label('sumCh2')).filter(callDetails.lt.dcontext == "callback", callDetails.lt.channel.like('SIP/10.0.0.21%'), callDetails.lt.calldate.between(date, dateRange)) | ||
34 | # sumCh3_query = callDetails.lt.query.with_entities(func.sum(callDetails.lt.duration).label('sumCh3')).filter(callDetails.lt.dcontext == "callback", callDetails.lt.channel.like('SIP/10.0.0.22%'), callDetails.lt.calldate.between(date, dateRange)) | ||
35 | 30 | ||
36 | # average = 0 | ||
37 | # sum = 0 | ||
38 | # sumCh1 = 0 | ||
39 | # sumCh2 = 0 | ||
40 | # sumCh3 = 0 | ||
41 | # for res in sumCh1_query.all(): | ||
42 | # sumCh1 = res.sumCh1/60 | ||
43 | |||
44 | # for res in sumCh2_query.all(): | ||
45 | # sumCh2 = res.sumCh2/60 | ||
46 | |||
47 | # for res in sumCh3_query.all(): | ||
48 | # sumCh3 = res.sumCh3/60 | ||
49 | |||
50 | # for res in avg_query.all(): | ||
51 | # average = res.average/60 #The duration recorded is in seconds, convert it to | ||
52 | # #minutes | ||
53 | # sum = res.sum/60 | ||
54 | |||
55 | 31 | print '{0}: {1}'.format("Number of missed calls", callDetails.missedCalls(startDate, endDate)) | |
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')) | ||
56 | 34 | print '{0}: {1}'.format("Number of calls answered", callDetails.answeredCalls(startDate, endDate)) | |
57 | print '{0}: {1}'.format("Average length of calls", average_call_length) | ||
58 | print '{0}: {1}'.format("Total number of audio minutes played", audio_minutes) | ||
59 | print '{0}: {1}'.format("Audio minutes on channel 10.0.0.20", channel1_minutes) | ||
60 | print '{0}: {1}'.format("Audio minutes on channel 10.0.0.21", channel2_minutes) | ||
61 | print '{0}: {1}'.format("Audio minutes on channel 10.0.0.22", channel3_minutes) | ||
62 | print '{0}: {1}'.format("Load on channel 10.0.0.20", channel1_minutes/audio_minutes) | ||
63 | print '{0}: {1}'.format("Load on channel 10.0.0.21", channel2_minutes/audio_minutes) | ||
64 | print '{0}: {1}'.format("Load on channel 10.0.0.22", channel3_minutes/audio_minutes) | ||
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) |