Nuevos modulos para analisis
This commit is contained in:
parent
e304069684
commit
d71b69a611
4 changed files with 137 additions and 1 deletions
|
|
@ -96,6 +96,30 @@ class CapturasInterface:
|
|||
|
||||
self.anunciosdb.query(query_statement, query_parameters)
|
||||
|
||||
def get_market_snapshot(self, start_date, end_date):
|
||||
query_statement = """
|
||||
SELECT *
|
||||
FROM `anuncios`.`capturas` `t1`
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
`t1`.`fecha_captura` =
|
||||
(
|
||||
SELECT
|
||||
max(`t2`.`fecha_captura`)
|
||||
FROM `anuncios`.`capturas` `t2`
|
||||
WHERE (`t1`.`referencia` = `t2`.`referencia`)
|
||||
)
|
||||
)
|
||||
AND (`t1`.`fecha_captura` BETWEEN %(start_date)S AND %(end_date)S)
|
||||
)
|
||||
"""
|
||||
query_parameters = {'start_date': start_date.strftime('%Y-%m-%d 00:00:00'),
|
||||
'end_date': end_date.strftime('%Y-%m-%d 00:00:00')}
|
||||
|
||||
cursor_result = self.anunciosdb.query(query_statement, query_parameters, dictionary=True)
|
||||
return cursor_result.fetchall()
|
||||
|
||||
|
||||
capturas_interface = CapturasInterface()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue