asterisk_mini_statement 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b9a567d9c511d2eb0980b65830e34d1976e383d
4
- data.tar.gz: db23f88b30b410e41f03ecda7fc8fcec9dc677ad
3
+ metadata.gz: c13c22c873c5639258a9ebfcee0cc65e6fd81585
4
+ data.tar.gz: 52a662d74c97cc39a8801691c6732783446f2f39
5
5
  SHA512:
6
- metadata.gz: 5e5edd4c9f2be60c2012be9d1b90305f975616bfd570291bb683fce02e385115126f9c9ba62cb8d1205d7471d8f280d7b8e812bbf6a1c60c97fc09c9eefcee3b
7
- data.tar.gz: 35ed3be2c374225a4e741ee5e64265894cdf80051da099165b29ac9c92e3f6cdc14fcb7bd26026e9edcc624631cfb1c4d572f498d939c4db7f96b6213430fb4e
6
+ metadata.gz: 4a329cb3670bcb27686f64b15fbae1b74ad021bfc8d256443489a8f88e3a388a568430ef52bb303fa5cdd004b4dda72d4d7c3e2190790a2935135acd0271a4f3
7
+ data.tar.gz: 62459d67951f77f39d3dc8dad190f5c0ba7609a43a36efeced2de039d2ea705b8c26eff8484f671779591f1dbe722c86814e572b1b0b3cba0d2d05909508271d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -25,7 +25,7 @@ class AsteriskMiniStatement
25
25
  def initialize(cdr_file='/var/log/asterisk/cdr-csv/Master.csv',
26
26
  startdate: (Date.today - 8).strftime("%d-%b-%Y"),
27
27
  enddate: (Date.today - 1).strftime("%d-%b-%Y"),
28
- telno: 'unknown', outgoing_regex: /SIP\/(\d+)@sipgate,30,tr/)
28
+ telno: 'unknown', outgoing_regex: /SIP\/(\d+)@/)
29
29
 
30
30
  sdate = Date.parse startdate
31
31
  edate = Date.parse enddate
@@ -36,25 +36,24 @@ class AsteriskMiniStatement
36
36
  lastapp lastdata start answer end duration billsec disposition
37
37
  amaflags astid)
38
38
 
39
- a = s.lines.map {|line| Hash[headings.zip(CSV.parse(line).first)] }
39
+ lines = s.lines.map {|line| Hash[headings.zip(CSV.parse(line).first)] }
40
40
 
41
41
 
42
- a2 = a.select do |x|
42
+ lines.select! do |x|
43
43
  date = Date.parse(x[:start])
44
44
  date >= sdate and date <= edate and \
45
45
  x[:disposition] == 'ANSWERED' and x[:lastapp] == 'Dial'
46
46
  end
47
47
 
48
- a3 = a2.group_by {|x| Date.parse(x[:start]) }
48
+ days = lines.group_by {|x| Date.parse(x[:start]) }
49
49
 
50
50
  px = Polyrex.new('calls[telno, period]/day[date]/item[time, telno,' +
51
51
  ' io, dur]')
52
-
52
+ px.summary.telno = telno
53
53
  px.summary.period = "%s - %s" % [sdate.strftime("%d/%m/%Y"),
54
54
  edate.strftime("%d/%m/%Y")]
55
- px.summary.telno = telno
56
-
57
- a3.each do |day, items|
55
+
56
+ days.each do |day, items|
58
57
 
59
58
  px.create_day({date: day.strftime("%d-%b-%Y")}) do |create|
60
59
 
@@ -62,12 +61,9 @@ class AsteriskMiniStatement
62
61
 
63
62
  outgoing = x[:lastdata][outgoing_regex,1]
64
63
 
65
- io, telno = if outgoing then
66
- io = ['out', outgoing]
67
- else
68
- telno = ['in', x[:clid][/"([^"]+)/,1]]
69
- end
70
-
64
+ io, telno = outgoing ? ['out', outgoing] :
65
+ ['in', x[:clid][/"([^"]+)/,1]]
66
+
71
67
  raw_a = Subunit.new(units={minutes:60, hours:60},
72
68
  seconds: x[:duration].to_i).to_a
73
69
 
@@ -76,8 +72,8 @@ class AsteriskMiniStatement
76
72
  val > 0 ? r << (val.to_s + label) : r
77
73
  end.take 2
78
74
 
79
- time = x[:start][/\d{2}:\d{2}/]
80
- create.item(time: time, telno: telno, io: io, dur: a.join(' ') )
75
+ create.item(time: x[:start][/\d{2}:\d{2}/], telno: telno,
76
+ io: io, dur: a.join(' ') )
81
77
  end
82
78
 
83
79
  end
@@ -102,6 +98,7 @@ Date/time Telephone duration
102
98
  ========= =========== ========"
103
99
 
104
100
  records = px.records.inject('') do |r, day|
101
+
105
102
  date = Date.parse(day.date)
106
103
  r << "\n" + date.strftime("%A #{date.day.ordinalize} %B %Y") + "\n\n"
107
104
 
@@ -109,8 +106,7 @@ Date/time Telephone duration
109
106
 
110
107
  r2 << (x.io == 'in' ? '>' : '<')
111
108
  r2 << Time.parse(x.time).strftime(" %l:%M%P: ")
112
- r2 << x.telno.ljust(13)
113
- r2 << x.dur.rjust(8) + "\n"
109
+ r2 << x.telno.ljust(13) + x.dur.rjust(8) + "\n"
114
110
  end
115
111
 
116
112
  r << "\n" + '-' * 32 + "\n"
@@ -120,4 +116,4 @@ Date/time Telephone duration
120
116
 
121
117
  end
122
118
 
123
- end
119
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asterisk_mini_statement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  nvlgfc5b1kUBa0viP6I53DUsYpTa1sWNpVQoXGEIIgB46Gtx/+fY83adQ3SrThtn
32
32
  MbY57VwNAM4kow==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-05-15 00:00:00.000000000 Z
34
+ date: 2016-05-16 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: subunit
metadata.gz.sig CHANGED
Binary file