Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
scrapper-portabilidad
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier
scrapper-portabilidad
Commits
75b0991f
Commit
75b0991f
authored
May 07, 2025
by
Javier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actualizacion en funcion get_cdr, para obtener datos de ddi en magnus que tengan el +34
parent
00b45e98
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
launch.json
.vscode/launch.json
+1
-0
cli.py
cli.py
+5
-4
functions.py
mbilling/functions.py
+15
-8
No files found.
.vscode/launch.json
View file @
75b0991f
...
...
@@ -4,6 +4,7 @@
//
For
more
information
,
visit
:
https
:
//go.microsoft.com/fwlink/?linkid=
830387
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"name"
:
"API"
,
"type"
:
"python"
,
...
...
cli.py
View file @
75b0991f
...
...
@@ -295,13 +295,14 @@ def add_cdrs() -> 'list[dict]':
# Obtención de Parámetros
sip_accounts
=
list
(
get_accounts
(
only_postpaid
=
True
))
last_update
=
get_last_updated_cdr
(
*
[
sip
.
callerid
for
sip
in
sip_accounts
])
# Filtrar cuentas válidas (ni None ni sin callerid)
valid_accounts
=
[
acc
for
acc
in
sip_accounts
if
acc
and
acc
.
callerid
]
last_update
=
get_last_updated_cdr
(
*
[
acc
.
callerid
for
acc
in
valid_accounts
])
cdrs
=
[]
# Carga en Memoria de CDRs
for
account
in
sip_accounts
:
since
=
last_update
[
account
.
callerid
]
if
account
.
callerid
in
last_update
.
keys
(
)
else
None
for
account
in
valid_accounts
:
since
=
last_update
.
get
(
account
.
callerid
)
# Más seguro que usar in + []
cdrs
.
extend
(
get_cdrs
(
phone_number
=
account
.
callerid
,
since
=
since
))
# Almacenamiento en Servidor SQL
...
...
mbilling/functions.py
View file @
75b0991f
...
...
@@ -391,29 +391,29 @@ def get_cdrs(phone_number: str, since: datetime = None, upto: datetime = None) -
cursor
.
execute
(
'SELECT callerid, calledstation dest, destination as description, starttime date, sessiontime duration, ROUND(sessionbill,3)
\
price, ROUND(buycost,3) cost FROM mbilling.pkg_cdr c INNER JOIN mbilling.pkg_prefix as p ON p.id = id_prefix
\
WHERE callerid
=
? AND starttime > ? AND starttime <= ?'
,
(
phone_number
,
since
,
upto
)
WHERE callerid
LIKE
? AND starttime > ? AND starttime <= ?'
,
(
'
%
'
+
phone_number
+
'
%
'
,
since
,
upto
)
)
elif
since
:
cursor
.
execute
(
'SELECT callerid, calledstation dest, destination as description, starttime date, sessiontime duration, ROUND(sessionbill,3)
\
price, ROUND(buycost,3) cost FROM mbilling.pkg_cdr INNER JOIN mbilling.pkg_prefix as p ON p.id = id_prefix
\
WHERE callerid
=
? AND starttime > ?'
,
(
phone_number
,
since
)
WHERE callerid
LIKE
? AND starttime > ?'
,
(
'
%
'
+
phone_number
+
'
%
'
,
since
)
)
elif
upto
:
cursor
.
execute
(
'SELECT callerid, calledstation dest, destination as description, starttime date, sessiontime duration, ROUND(sessionbill,3)
\
price, ROUND(buycost,3) cost FROM mbilling.pkg_cdr INNER JOIN mbilling.pkg_prefix as p ON p.id = id_prefix
\
WHERE callerid
=
? AND starttime <= ?'
,
(
phone_number
,
upto
)
WHERE callerid
LIKE
? AND starttime <= ?'
,
(
'
%
'
+
phone_number
+
'
%
'
,
upto
)
)
else
:
cursor
.
execute
(
'SELECT callerid, calledstation dest, destination as description, starttime date, sessiontime duration, ROUND(sessionbill,3)
\
price, ROUND(buycost,3) cost FROM mbilling.pkg_cdr INNER JOIN mbilling.pkg_prefix as p ON p.id = id_prefix
\
WHERE callerid
=
?'
,
(
phone_number
,)
WHERE callerid
LIKE
?'
,
(
'
%
'
+
phone_number
+
'
%
'
,)
)
data
=
cursor
.
fetchall
()
...
...
@@ -422,6 +422,13 @@ def get_cdrs(phone_number: str, since: datetime = None, upto: datetime = None) -
headers
=
[
'callerid'
,
'destination'
,
'description'
,
'timestamp'
,
'duration'
,
'price'
,
'cost'
]
for
line
in
data
:
# Modificamos el callerid si empieza con '+34'
if
line
[
0
]
.
startswith
(
'+34'
):
line
=
list
(
line
)
# Convertimos la tupla en lista para modificar elementos
line
[
0
]
=
line
[
0
][
3
:]
# Quitamos el '+34' (3 caracteres)
line
=
tuple
(
line
)
# Volvemos a convertirlo en tupla
# Añadimos la línea al resultado final
cdr
.
append
(
dict
(
zip
(
headers
,
line
)))
return
cdr
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment