@@ -49,6 +49,13 @@ async def get_cdr_uniqueid(self, uniqueid):
4949 uniqueid -- id of call in asterisk
5050 """
5151
52+ async def get_cdr_uniqueid_or_linkedid (self , uniqueid ):
53+ """Return calls history
54+
55+ Arguments:
56+ uniqueid -- id of call in asterisk
57+ """
58+
5259 async def get_cdr (self , start_date , end_date , uniqueid = None ):
5360 """Return calls history
5461
@@ -102,6 +109,20 @@ async def get_cdr_uniqueid(self, uniqueid):
102109 result .append (row )
103110 return result
104111
112+ async def get_cdr_uniqueid_or_linkedid (self , uniqueid ):
113+ import aiosqlite
114+
115+ result = []
116+ async with aiosqlite .connect (self .config .db_host ) as database :
117+ database .row_factory = aiosqlite .Row
118+ async with database .execute (
119+ f"SELECT * FROM { self .config .db_table_cdr_name } where uniqueid= %s or linkedid = %s;" ,
120+ [uniqueid , uniqueid ],
121+ ) as cursor :
122+ async for row in cursor :
123+ result .append (row )
124+ return result
125+
105126 async def get_cdr (self , start_date , end_date ):
106127 import aiosqlite
107128
@@ -202,6 +223,17 @@ async def get_cdr_uniqueid(self, uniqueid):
202223 conn .close ()
203224 return rows
204225
226+ async def get_cdr_uniqueid_or_linkedid (self , uniqueid ):
227+ conn , cur = await self .get_conn_cur ()
228+ await cur .execute (
229+ f"SELECT * FROM { self .config .db_table_cdr_name } where uniqueid = %s or linkedid = %s;" ,
230+ (uniqueid , uniqueid ),
231+ )
232+ rows = await cur .fetchall ()
233+ await cur .close ()
234+ conn .close ()
235+ return rows
236+
205237 async def get_cdr (self , start_date , end_date ):
206238 conn , cur = await self .get_conn_cur ()
207239 await cur .execute (
@@ -280,6 +312,16 @@ async def get_cdr_uniqueid(self, uniqueid):
280312 await conn .close ()
281313 return rows
282314
315+ async def get_cdr_uniqueid_or_linkedid (self , uniqueid ):
316+ conn , cur = await self .get_conn_cur ()
317+ await cur .execute (
318+ f"SELECT * FROM { self .config .db_table_cdr_name } where uniqueid = %s or linkedid = %s;" ,
319+ (uniqueid , uniqueid ),
320+ )
321+ rows = await cur .fetchall ()
322+ await conn .close ()
323+ return rows
324+
283325 async def get_cdr (self , start_date , end_date ):
284326 conn , cur = await self .get_conn_cur ()
285327 await cur .execute (
0 commit comments